diff options
77 files changed, 114 insertions, 4413 deletions
diff --git a/app/build.gradle b/app/build.gradle index 0b5165b0..4c9f6a25 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -4,19 +4,29 @@ import java.util.regex.Pattern apply plugin: 'com.android.application' android { - compileSdkVersion 33 ndkVersion "21.4.7075529" - buildToolsVersion '33.0.2' + namespace = "se.leap.bitmaskclient" compileOptions { - targetCompatibility 1.8 - sourceCompatibility 1.8 + targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_17 } viewBinding { enabled = true } + packaging { + jniLibs { + useLegacyPackaging = true + } + } + + buildFeatures { + buildConfig true + aidl true + } + defaultConfig { applicationId "se.leap.bitmaskclient" // the factor 1000 is used so that gplay users can upgrade from split apks ((current version number - 1) * 1000) + n @@ -24,6 +34,7 @@ android { // however we don't calculate the versionCode here, because F-Droid doesn't like that versionCode 169000 versionName "1.1.8" + compileSdk 33 minSdkVersion 21 targetSdkVersion 33 vectorDrawables.useSupportLibrary = true @@ -106,9 +117,6 @@ android { production { dimension "implementation" } - insecure { - dimension "implementation" - } normal { dimension "branding" @@ -297,7 +305,7 @@ android { 'ovpnlibs/assets', '../ics-openvpn/main/build/ovpnassets', ] - jniLibs.srcDirs = ['../ics-openvpn/main/build/intermediates/cmake/skeletonRelease/obj/'] + jniLibs.srcDirs = ['../ics-openvpn/main/build/intermediates/cmake/skeletonOvpn2Release/obj/'] jni.srcDirs = [] //disable automatic ndk-build } @@ -344,7 +352,6 @@ android { * normalProductionFatDebug -> Bitmask development build, includes all ABIS * customProductionFatwebDebug -> branded development build, includes all ABIs, for distribution through a download page * normalProductionFatWebDebug -> Bitmask development build, includes all ABIS, for distribution through a download page - * normalInsecureFatDebug -> Bitmask development build, doesn't checks certificates (for test server setup w/o valid certificates), includes all ABIs * * Branded Releases: * ----------------- @@ -378,11 +385,7 @@ android { def supportsSplitApk = variant.flavors[0].splitApk def branding = variant.flavors[0].name // To check for a certain build type, use variant.buildType.name == "<buildType>" - if (((names.contains("insecure") && !names.contains("fat")) || - (names.contains("insecure") && buildTypeName.contains("beta")) || - (names.contains("insecure") && buildTypeName.contains("release")) || - (names.contains("insecure") && branding.contains("custom")) || - (buildTypeName.contains("debug") && !(names.contains("fatweb") || names.contains("fat"))) || + if (((buildTypeName.contains("debug") && !(names.contains("fatweb") || names.contains("fat"))) || (names.contains("fatweb") && buildTypeName.contains("beta")) || (!supportsSplitApk && !names.contains("fat"))) ) { @@ -415,16 +418,10 @@ dependencies { androidTestImplementation 'tools.fastlane:screengrab:2.1.1' testImplementation 'tools.fastlane:screengrab:2.1.1' - testImplementation 'org.json:json:20180813' androidTestImplementation 'androidx.test.ext:junit:1.1.4' debugImplementation 'com.squareup.leakcanary:leakcanary-android-core:2.9.1' - annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' - annotationProcessor 'com.squareup.dagger:dagger-compiler:1.2.2' - implementation 'com.jakewharton:butterknife:10.2.1' - //TODO: replace that library - compileOnly 'com.squareup.dagger:dagger-compiler:1.2.2' - implementation 'com.github.pedrovgs:renderers:1.5' + implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.squareup.okhttp3:okhttp:4.10.0' implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.10.0' @@ -504,7 +501,7 @@ subprojects { afterEvaluate {project -> if (project.hasProperty("android")) { android { - compileSdkVersion 31 + compileSdkVersion 33 } } } diff --git a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadBroadcastReceiver.java b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadBroadcastReceiver.java index 5591454b..1c689566 100644 --- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadBroadcastReceiver.java +++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/DownloadBroadcastReceiver.java @@ -16,16 +16,6 @@ */ package se.leap.bitmaskclient.appUpdate; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.widget.Toast; - -import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.base.models.Constants; -import se.leap.bitmaskclient.base.utils.PreferenceHelper; - import static android.app.Activity.RESULT_CANCELED; import static se.leap.bitmaskclient.appUpdate.DownloadService.DOWNLOAD_PROGRESS; import static se.leap.bitmaskclient.appUpdate.DownloadService.NO_NEW_VERISON; @@ -39,6 +29,16 @@ import static se.leap.bitmaskclient.appUpdate.DownloadServiceCommand.DOWNLOAD_UP import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_DOWNLOAD_SERVICE_EVENT; import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_CODE; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.widget.Toast; + +import se.leap.bitmaskclient.R; +import se.leap.bitmaskclient.base.models.Constants; +import se.leap.bitmaskclient.base.utils.PreferenceHelper; + public class DownloadBroadcastReceiver extends BroadcastReceiver { public static final String ACTION_DOWNLOAD = "se.leap.bitmaskclient.appUpdate.ACTION_DOWNLOAD"; @@ -69,7 +69,7 @@ public class DownloadBroadcastReceiver extends BroadcastReceiver { break; case UPDATE_NOT_FOUND: if (resultData.getBoolean(NO_NEW_VERISON, false)) { - PreferenceHelper.setLastAppUpdateCheck(context.getApplicationContext()); + PreferenceHelper.setLastAppUpdateCheck(); } break; case UPDATE_DOWNLOADED: diff --git a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java index 69c6feb3..92291a43 100644 --- a/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java +++ b/app/src/fatweb/java/se.leap.bitmaskclient/appUpdate/InstallActivity.java @@ -55,7 +55,7 @@ public class InstallActivity extends Activity { } protected void installUpdate() { - PreferenceHelper.restartOnUpdate(this.getApplicationContext(), true); + PreferenceHelper.restartOnUpdate(true); Intent installIntent = new Intent(Intent.ACTION_VIEW); File update = UpdateDownloadManager.getUpdateFile(this.getApplicationContext()); diff --git a/app/src/insecure/AndroidManifest.xml b/app/src/insecure/AndroidManifest.xml deleted file mode 100644 index a720b777..00000000 --- a/app/src/insecure/AndroidManifest.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- - Copyright (C) 2011 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="se.leap.bitmaskclient"> - - <!-- if you want to run test, this permissions are needed. Gradle will get rid of them once we implement it. --> - <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> - <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/> - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> - <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> - -</manifest> diff --git a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/AddProviderActivity.java b/app/src/insecure/java/se/leap/bitmaskclient/providersetup/AddProviderActivity.java deleted file mode 100644 index 6d23c48d..00000000 --- a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/AddProviderActivity.java +++ /dev/null @@ -1,92 +0,0 @@ -package se.leap.bitmaskclient.providersetup; - -import android.os.Bundle; -import android.view.View; -import android.widget.Button; -import android.widget.CheckBox; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; - -import androidx.annotation.Nullable; - -import butterknife.BindView; -import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.providersetup.activities.AddProviderBaseActivity; - -import static android.widget.RelativeLayout.BELOW; -import static android.widget.RelativeLayout.LEFT_OF; -import static se.leap.bitmaskclient.base.models.Constants.DANGER_ON; - -public class AddProviderActivity extends AddProviderBaseActivity { - - final public static String TAG = "AddProviderActivity"; - - @BindView(R.id.danger_checkbox) - CheckBox checkboxDanger; - - @BindView(R.id.button_save) - Button saveButton; - - @Nullable - @BindView(R.id.button_container) - LinearLayout buttonContainer; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.a_add_provider); - init(); - - checkboxDanger.setVisibility(View.VISIBLE); - checkboxDanger.setText(R.string.danger_checkbox); - checkboxDanger.setChecked(preferences.getBoolean(DANGER_ON, false)); - } - - @Override - public void setupSaveButton() { - saveButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - preferences.edit().putBoolean(DANGER_ON, checkboxDanger.isChecked()).apply(); - saveProvider(); - } - }); - } - - @Override - protected void showCompactLayout() { - if (isCompactLayout) { - return; - } - super.showCompactLayout(); - showCompactButtonLayout(); - } - - @Override - protected void showStandardLayout() { - if (!isCompactLayout) { - return; - } - super.showStandardLayout(); - showStandardButtonLayout(); - } - - private void showCompactButtonLayout() { - RelativeLayout.LayoutParams phoneButtonContainerParams = (RelativeLayout.LayoutParams) buttonContainer.getLayoutParams(); - phoneButtonContainerParams.addRule(BELOW, 0); - buttonContainer.setLayoutParams(phoneButtonContainerParams); - - RelativeLayout.LayoutParams checkBoxParams = (RelativeLayout.LayoutParams) checkboxDanger.getLayoutParams(); - checkBoxParams.addRule(LEFT_OF, R.id.button_container); - checkboxDanger.setLayoutParams(checkBoxParams); - } - - private void showStandardButtonLayout() { - RelativeLayout.LayoutParams phoneButtonContainerParams = (RelativeLayout.LayoutParams) buttonContainer.getLayoutParams(); - phoneButtonContainerParams.addRule(BELOW, R.id.danger_checkbox); - buttonContainer.setLayoutParams(phoneButtonContainerParams); - - RelativeLayout.LayoutParams checkBoxParams = (RelativeLayout.LayoutParams) checkboxDanger.getLayoutParams(); - checkBoxParams.addRule(LEFT_OF, 0); - checkboxDanger.setLayoutParams(checkBoxParams); - } -} diff --git a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java b/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java deleted file mode 100644 index 221871ef..00000000 --- a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderApiManager.java +++ /dev/null @@ -1,480 +0,0 @@ -/** - * Copyright (c) 2018 LEAP Encryption Access Project and contributers - * - * 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, see <http://www.gnu.org/licenses/>. - */ - -package se.leap.bitmaskclient.providersetup; - -import android.content.SharedPreferences; -import android.content.res.Resources; -import static se.leap.bitmaskclient.BuildConfig.DEBUG_MODE; -import android.os.Bundle; -import android.util.Pair; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.URL; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.List; -import java.util.Scanner; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.KeyManager; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import de.blinkt.openvpn.core.VpnStatus; -import okhttp3.OkHttpClient; -import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.base.models.Provider; -import se.leap.bitmaskclient.base.utils.ConfigHelper; -import se.leap.bitmaskclient.eip.EIP; -import se.leap.bitmaskclient.providersetup.connectivity.OkHttpClientGenerator; - -import static android.text.TextUtils.isEmpty; -import static se.leap.bitmaskclient.R.string.certificate_error; -import static se.leap.bitmaskclient.R.string.downloading_vpn_certificate_failed; -import static se.leap.bitmaskclient.R.string.error_io_exception_user_message; -import static se.leap.bitmaskclient.R.string.malformed_url; -import static se.leap.bitmaskclient.R.string.setup_error_text; -import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_cert; -import static se.leap.bitmaskclient.R.string.warning_corrupted_provider_details; -import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_KEY; -import static se.leap.bitmaskclient.base.models.Constants.DANGER_ON; -import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY; -import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_VPN_CERTIFICATE; -import static se.leap.bitmaskclient.base.utils.ConfigHelper.getProviderFormattedString; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.ERRORS; -import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_CERTIFICATE_PINNING; -import static se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog.DOWNLOAD_ERRORS.ERROR_CORRUPTED_PROVIDER_JSON; -import static se.leap.bitmaskclient.tor.TorStatusObservable.getProxyPort; - -/** - * Created by cyberta on 04.01.18. - */ - -public class ProviderApiManager extends ProviderApiManagerBase { - - private static final String TAG = ProviderApiManagerBase.class.getName(); - - protected static boolean lastDangerOn = true; - - - public ProviderApiManager(SharedPreferences preferences, Resources resources, OkHttpClientGenerator clientGenerator, ProviderApiServiceCallback callback) { - super(preferences, resources, clientGenerator, callback); - } - - public static boolean lastDangerOn() { - return lastDangerOn; - } - - /** - * Downloads a provider.json from a given URL, adding a new provider using the given name. - * - * @param task containing a boolean meaning if the provider is custom or not, another boolean meaning if the user completely trusts this provider, the provider name and its provider.json url. - * @return a bundle with a boolean value mapped to a key named BROADCAST_RESULT_KEY, and which is true if the update was successful. - */ - @Override - protected Bundle setUpProvider(Provider provider, Bundle task) { - Bundle currentDownload = new Bundle(); - - if (task != null) { - lastDangerOn = task.containsKey(DANGER_ON) && task.getBoolean(DANGER_ON); - } - - if (isEmpty(provider.getMainUrlString()) || provider.getMainUrl().isDefault()) { - setErrorResult(currentDownload, malformed_url, null); - currentDownload.putParcelable(PROVIDER_KEY, provider); - VpnStatus.logWarning("[API] MainURL String is not set. Cannot setup provider."); - return currentDownload; - } - - getPersistedProviderUpdates(provider); - currentDownload = validateProviderDetails(provider); - - //provider details invalid - if (currentDownload.containsKey(ERRORS)) { - currentDownload.putParcelable(PROVIDER_KEY, provider); - return currentDownload; - } - - //no provider certificate available - if (currentDownload.containsKey(BROADCAST_RESULT_KEY) && !currentDownload.getBoolean(BROADCAST_RESULT_KEY)) { - resetProviderDetails(provider); - } - - currentDownload = getAndSetProviderJson(provider, lastDangerOn); - if (provider.hasDefinition() || (currentDownload.containsKey(BROADCAST_RESULT_KEY) && currentDownload.getBoolean(BROADCAST_RESULT_KEY))) { - if (!provider.hasCaCert()) - currentDownload = downloadCACert(provider, lastDangerOn); - if (provider.hasCaCert() || (currentDownload.containsKey(BROADCAST_RESULT_KEY) && currentDownload.getBoolean(BROADCAST_RESULT_KEY))) { - currentDownload = getAndSetEipServiceJson(provider); - } - if (provider.hasEIP() && !provider.allowsRegistered() && !provider.allowsAnonymous()) { - setErrorResult(currentDownload, setup_error_text, null); - } - } - currentDownload.putParcelable(PROVIDER_KEY, provider); - return currentDownload; - } - - private Bundle getAndSetProviderJson(Provider provider, boolean dangerOn) { - Bundle result = new Bundle(); - - JSONObject providerDefinition = provider.getDefinition(); - String providerMainUrl = provider.getMainUrlString(); - - String providerDotJsonString; - if(providerDefinition.length() == 0 || provider.getCaCert().isEmpty()) - providerDotJsonString = downloadWithCommercialCA(providerMainUrl + "/provider.json", dangerOn); - else - providerDotJsonString = downloadFromApiUrlWithProviderCA("/provider.json", provider, dangerOn); - - if (ConfigHelper.checkErroneousDownload(providerDotJsonString) || !isValidJson(providerDotJsonString)) { - setErrorResult(result, malformed_url, null); - return result; - } - - if (DEBUG_MODE) { - VpnStatus.logDebug("[API] PROVIDER JSON: " + providerDotJsonString); - } - - try { - JSONObject providerJson = new JSONObject(providerDotJsonString); - - if (provider.define(providerJson)) { - result.putBoolean(BROADCAST_RESULT_KEY, true); - } else { - return setErrorResult(result, warning_corrupted_provider_details, ERROR_CORRUPTED_PROVIDER_JSON.toString()); - } - - result.putBoolean(BROADCAST_RESULT_KEY, true); - } catch (JSONException e) { - setErrorResult(result, providerDotJsonString); - } - //TODO: check why the following line is not in production - result.putParcelable(PROVIDER_KEY, provider); - return result; - } - - /** - * Downloads the eip-service.json from a given URL, and saves eip service capabilities including the offered gateways - * @return a bundle with a boolean value mapped to a key named BROADCAST_RESULT_KEY, and which is true if the download was successful. - */ - @Override - protected Bundle getAndSetEipServiceJson(Provider provider) { - Bundle result = new Bundle(); - String eipServiceJsonString = ""; - try { - JSONObject providerDefinition = provider.getDefinition(); - String eipServiceUrl = providerDefinition.getString(Provider.API_URL) + "/" + providerDefinition.getString(Provider.API_VERSION) + "/" + EIP.SERVICE_API_PATH; - eipServiceJsonString = downloadWithProviderCA(provider.getCaCert(), eipServiceUrl, lastDangerOn); - if (DEBUG_MODE) { - VpnStatus.logDebug("[API] EIP SERVICE JSON: " + eipServiceJsonString); - } - - JSONObject eipServiceJson = new JSONObject(eipServiceJsonString); - - if (eipServiceJson.has(ERRORS)) { - setErrorResult(result, eipServiceJsonString); - } else{ - provider.setEipServiceJson(eipServiceJson); - provider.setLastEipServiceUpdate(System.currentTimeMillis()); - result.putBoolean(BROADCAST_RESULT_KEY, true); - } - } catch (NullPointerException | JSONException e) { - setErrorResult(result, R.string.error_json_exception_user_message, null); - } - //TODO: check why the following line is not in production - result.putParcelable(PROVIDER_KEY, provider); - return result; - } - - /** - * Downloads a new OpenVPN certificate, attaching authenticated cookie for authenticated certificate. - * - * @return true if certificate was downloaded correctly, false if provider.json is not present in SharedPreferences, or if the certificate url could not be parsed as a URI, or if there was an SSL error. - */ - @Override - protected Bundle updateVpnCertificate(Provider provider) { - Bundle result = new Bundle(); - try { - URL newCertStringUrl = new URL(provider.getApiUrlWithVersion() + "/" + PROVIDER_VPN_CERTIFICATE); - - String certString = downloadWithProviderCA(provider.getCaCert(), newCertStringUrl.toString(), lastDangerOn); - if (DEBUG_MODE) { - VpnStatus.logDebug("[API] VPN CERT: " + certString); - } - if (ConfigHelper.checkErroneousDownload(certString)) { - if (certString == null || certString.isEmpty()) { - // probably 204 - setErrorResult(result, error_io_exception_user_message, null); - } else { - setErrorResult(result, certString); - return result; - } - } - result = loadCertificate(provider, certString); - } catch (IOException e) { - setErrorResult(result, downloading_vpn_certificate_failed, null); - e.printStackTrace(); - } - //TODO: check why the following line is not in production - result.putParcelable(PROVIDER_KEY, provider); - return result; - } - - /** - * Fetches the Geo ip Json, containing a list of gateways sorted by distance from the users current location - * - * @param provider - * @return - */ - @Override - protected Bundle getGeoIPJson(Provider provider) { - Bundle result = new Bundle(); - - if (!provider.shouldUpdateGeoIpJson() || provider.getGeoipUrl().isDefault()) { - result.putBoolean(BROADCAST_RESULT_KEY, false); - return result; - } - - - try { - URL geoIpUrl = provider.getGeoipUrl().getUrl(); - - String geoipJsonString = downloadFromUrlWithProviderCA(geoIpUrl.toString(), provider, lastDangerOn); - if (DEBUG_MODE) { - VpnStatus.logDebug("[API] MENSHEN JSON: " + geoipJsonString); - } - JSONObject geoipJson = new JSONObject(geoipJsonString); - - if (geoipJson.has(ERRORS)) { - result.putBoolean(BROADCAST_RESULT_KEY, false); - } else { - provider.setGeoIpJson(geoipJson); - provider.setLastEipServiceUpdate(System.currentTimeMillis()); - result.putBoolean(BROADCAST_RESULT_KEY, true); - } - - - } catch (JSONException | NullPointerException e) { - result.putBoolean(BROADCAST_RESULT_KEY, false); - e.printStackTrace(); - } - return result; - } - - - private Bundle downloadCACert(Provider provider, boolean dangerOn) { - Bundle result = new Bundle(); - try { - String caCertUrl = provider.getDefinition().getString(Provider.CA_CERT_URI); - String providerDomain = provider.getDomain(); - - String certString = downloadWithCommercialCA(caCertUrl, dangerOn); - - if (validCertificate(provider, certString)) { - provider.setCaCert(certString); - if (DEBUG_MODE) { - VpnStatus.logDebug("[API] CA CERT: " + certString); - } - preferences.edit().putString(Provider.CA_CERT + "." + providerDomain, certString).apply(); - result.putBoolean(BROADCAST_RESULT_KEY, true); - } else { - setErrorResult(result, warning_corrupted_provider_cert, ERROR_CERTIFICATE_PINNING.toString()); - } - } catch (JSONException e) { - setErrorResult(result, malformed_url, null); - } - - return result; - } - - /** - * Tries to download the contents of the provided url using commercially validated CA certificate from chosen provider. - * <p/> - * If dangerOn flag is true, SSL exceptions will be managed by futher methods that will try to use some bypass methods. - * - * @param stringUrl - * @param dangerOn if the user completely trusts this provider - * @return - */ - private String downloadWithCommercialCA(String stringUrl, boolean dangerOn) { - String responseString; - JSONObject errorJson = new JSONObject(); - - OkHttpClient okHttpClient = clientGenerator.initCommercialCAHttpClient(errorJson, getProxyPort()); - if (okHttpClient == null) { - return errorJson.toString(); - } - - List<Pair<String, String>> headerArgs = getAuthorizationHeader(); - - responseString = sendGetStringToServer(stringUrl, headerArgs, okHttpClient); - - if (responseString != null && responseString.contains(ERRORS)) { - try { - // try to download with provider CA on certificate error - JSONObject responseErrorJson = new JSONObject(responseString); - if (dangerOn && responseErrorJson.getString(ERRORS).equals( - getProviderFormattedString(resources, R.string.certificate_error))) { - responseString = downloadWithoutCA(stringUrl); - } - } catch (JSONException e) { - e.printStackTrace(); - } - } - - return responseString; - } - - private String downloadFromApiUrlWithProviderCA(String path, Provider provider, boolean dangerOn) { - String baseUrl = provider.getApiUrlString(); - String urlString = baseUrl + path; - - return downloadFromUrlWithProviderCA(urlString, provider, dangerOn); - } - - private String downloadFromUrlWithProviderCA(String urlString, Provider provider, boolean dangerOn) { - String responseString; - JSONObject errorJson = new JSONObject(); - OkHttpClient okHttpClient = clientGenerator.initSelfSignedCAHttpClient(provider.getCaCert(), getProxyPort(), errorJson); - if (okHttpClient == null) { - return errorJson.toString(); - } - - List<Pair<String, String>> headerArgs = getAuthorizationHeader(); - responseString = sendGetStringToServer(urlString, headerArgs, okHttpClient); - - if (responseString != null && responseString.contains(ERRORS)) { - try { - // try to download with provider CA on certificate error - JSONObject responseErrorJson = new JSONObject(responseString); - if (dangerOn && responseErrorJson.getString(ERRORS).equals( - getProviderFormattedString(resources, R.string.certificate_error))) { - responseString = downloadWithCommercialCA(urlString, dangerOn); - } - } catch (JSONException e) { - e.printStackTrace(); - } - } - - return responseString; - } - - /** - * Tries to download the contents of the provided url using not commercially validated CA certificate from chosen provider. - * - * @param urlString as a string - * @param dangerOn true to download CA certificate in case it has not been downloaded. - * @return an empty string if it fails, the url content if not. - */ - private String downloadWithProviderCA(String caCert, String urlString, boolean dangerOn) { - JSONObject initError = new JSONObject(); - String responseString; - - OkHttpClient okHttpClient = clientGenerator.initSelfSignedCAHttpClient(caCert, getProxyPort(), initError); - if (okHttpClient == null) { - return initError.toString(); - } - - List<Pair<String, String>> headerArgs = getAuthorizationHeader(); - - responseString = sendGetStringToServer(urlString, headerArgs, okHttpClient); - - if (responseString.contains(ERRORS)) { - try { - // danger danger: try to download without CA on certificate error - JSONObject responseErrorJson = new JSONObject(responseString); - if (dangerOn && responseErrorJson.getString(ERRORS).equals( - getProviderFormattedString(resources, R.string.certificate_error))) { - responseString = downloadWithoutCA(urlString); - } - } catch (JSONException e) { - e.printStackTrace(); - } - } - - return responseString; - } - - /** - * Downloads the string that's in the url with any certificate. - */ - // This method is totally insecure anyways. So no need to refactor that in order to use okHttpClient, force modern TLS etc.. DO NOT USE IN PRODUCTION! - private String downloadWithoutCA(String urlString) { - String string = ""; - try { - - HostnameVerifier hostnameVerifier = new HostnameVerifier() { - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - - class DefaultTrustManager implements X509TrustManager { - - @Override - public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - } - - @Override - public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - } - - @Override - public X509Certificate[] getAcceptedIssuers() { - return null; - } - } - - SSLContext context = SSLContext.getInstance("TLS"); - context.init(new KeyManager[0], new TrustManager[]{new DefaultTrustManager()}, new SecureRandom()); - - URL url = new URL(urlString); - HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection(); - urlConnection.setSSLSocketFactory(context.getSocketFactory()); - urlConnection.setHostnameVerifier(hostnameVerifier); - string = new Scanner(urlConnection.getInputStream()).useDelimiter("\\A").next(); - System.out.println("String ignoring certificate = " + string); - } catch (FileNotFoundException e) { - e.printStackTrace(); - string = formatErrorMessage(malformed_url); - } catch (IOException e) { - // The downloaded certificate doesn't validate our https connection. - e.printStackTrace(); - string = formatErrorMessage(certificate_error); - } catch (NoSuchAlgorithmException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (KeyManagementException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return string; - } -} diff --git a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderDetailActivity.java b/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderDetailActivity.java deleted file mode 100644 index 2b62a7de..00000000 --- a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderDetailActivity.java +++ /dev/null @@ -1,17 +0,0 @@ -package se.leap.bitmaskclient.providersetup; - -import android.content.SharedPreferences; - -import se.leap.bitmaskclient.base.models.Constants; -import se.leap.bitmaskclient.providersetup.activities.AbstractProviderDetailActivity; - -public class ProviderDetailActivity extends AbstractProviderDetailActivity { - - @Override - public void onBackPressed() { - SharedPreferences.Editor editor = preferences.edit(); - editor.remove(Constants.DANGER_ON).apply(); - super.onBackPressed(); - } - -} diff --git a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderListActivity.java b/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderListActivity.java deleted file mode 100644 index 46eb2a05..00000000 --- a/app/src/insecure/java/se/leap/bitmaskclient/providersetup/ProviderListActivity.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2013 LEAP Encryption Access Project and contributors - * - * 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, see <http://www.gnu.org/licenses/>. - */ -package se.leap.bitmaskclient.providersetup; - -import android.os.Bundle; -import androidx.annotation.NonNull; - -import se.leap.bitmaskclient.base.models.Provider; -import se.leap.bitmaskclient.providersetup.activities.ProviderListBaseActivity; - -import static se.leap.bitmaskclient.base.models.Constants.DANGER_ON; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.SET_UP_PROVIDER; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.SETTING_UP_PROVIDER; - -/** - * Activity that builds and shows the list of known available providers. - * <p/> - * It also allows the user to enter custom providers with a button. - * - * @author parmegv - * @author cyberta - */ -public class ProviderListActivity extends ProviderListBaseActivity { - - @Override - protected void onItemSelectedLogic() { - boolean danger_on = preferences.getBoolean(DANGER_ON, true); - setUpProvider(danger_on); - } - - @Override - public void cancelSettingUpProvider() { - super.cancelSettingUpProvider(); - preferences.edit().remove(DANGER_ON).apply(); - } - - /** - * Asks ProviderAPI to download a new provider.json file - * - * @param danger_on tells if HTTPS client should bypass certificate errors - */ - public void setUpProvider(boolean danger_on) { - providerConfigState = SETTING_UP_PROVIDER; - - Bundle parameters = new Bundle(); - parameters.putBoolean(DANGER_ON, danger_on); - - ProviderAPICommand.execute(this, SET_UP_PROVIDER, parameters, provider); - } - - /** - * Retrys setup of last used provider, allows bypassing ca certificate validation. - */ - @Override - public void retrySetUpProvider(@NonNull Provider provider) { - providerConfigState = SETTING_UP_PROVIDER; - ProviderAPICommand.execute(this, SET_UP_PROVIDER, provider); - } - -} diff --git a/app/src/insecure/res/values/strings.xml b/app/src/insecure/res/values/strings.xml deleted file mode 100644 index 3e568115..00000000 --- a/app/src/insecure/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="danger_checkbox">Skip security check</string> -</resources> diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index cf4f6150..7d1ee39f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -92,21 +92,6 @@ android:name=".base.MainActivity" android:label="@string/app_name" android:launchMode="singleTop" /> - <activity - android:name=".providersetup.ProviderListActivity" - android:label="@string/configuration_wizard_title" /> - <activity - android:name=".providersetup.activities.CustomProviderSetupActivity" - android:label="@string/setup_provider" /> - <activity - android:name=".providersetup.AddProviderActivity" - android:label="@string/add_provider" /> - <activity - android:name=".providersetup.ProviderDetailActivity" - android:label="@string/provider_details_title" - android:launchMode="singleTop" /> - <activity android:name=".providersetup.activities.LoginActivity" /> - <activity android:name=".providersetup.activities.SignupActivity" /> <service android:name=".eip.EIP" diff --git a/app/src/main/java/se/leap/bitmaskclient/base/MainActivity.java b/app/src/main/java/se/leap/bitmaskclient/base/MainActivity.java index 7dd01ccb..5da238d4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/MainActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/MainActivity.java @@ -19,7 +19,6 @@ package se.leap.bitmaskclient.base; import static androidx.appcompat.app.ActionBar.DISPLAY_SHOW_CUSTOM; import static se.leap.bitmaskclient.R.string.downloading_vpn_certificate_failed; -import static se.leap.bitmaskclient.R.string.vpn_certificate_user_message; import static se.leap.bitmaskclient.base.models.Constants.ASK_TO_CANCEL_VPN; import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_CODE; import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_KEY; @@ -42,11 +41,9 @@ import static se.leap.bitmaskclient.providersetup.ProviderAPI.INCORRECTLY_UPDATE import static se.leap.bitmaskclient.providersetup.ProviderAPI.TOR_EXCEPTION; import static se.leap.bitmaskclient.providersetup.ProviderAPI.TOR_TIMEOUT; import static se.leap.bitmaskclient.providersetup.ProviderAPI.UPDATE_INVALID_VPN_CERTIFICATE; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.USER_MESSAGE; import android.content.Context; import android.content.Intent; -import android.graphics.Color; import android.os.Bundle; import android.util.Log; import android.view.Gravity; @@ -69,7 +66,6 @@ import se.leap.bitmaskclient.BuildConfig; import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.base.fragments.EipFragment; import se.leap.bitmaskclient.base.fragments.ExcludeAppsFragment; -import se.leap.bitmaskclient.base.fragments.LogFragment; import se.leap.bitmaskclient.base.fragments.MainActivityErrorDialog; import se.leap.bitmaskclient.base.fragments.MotdFragment; import se.leap.bitmaskclient.base.fragments.NavigationDrawerFragment; @@ -83,8 +79,6 @@ import se.leap.bitmaskclient.eip.EipCommand; import se.leap.bitmaskclient.eip.EipSetupListener; import se.leap.bitmaskclient.eip.EipSetupObserver; import se.leap.bitmaskclient.providersetup.ProviderAPI; -import se.leap.bitmaskclient.providersetup.activities.LoginActivity; -import se.leap.bitmaskclient.providersetup.models.LeapSRPSession; public class MainActivity extends AppCompatActivity implements EipSetupListener, Observer { @@ -310,10 +304,10 @@ public class MainActivity extends AppCompatActivity implements EipSetupListener, return; } - if (LeapSRPSession.loggedIn() || provider.allowsAnonymous()) { + if (provider.allowsAnonymous()) { showMainActivityErrorDialog(error); } else if (isInvalidCertificateForLoginOnlyProvider(error)) { - askUserToLogIn(getString(vpn_certificate_user_message)); + showMainActivityErrorDialog(getString(R.string.login_not_supported)); } } break; @@ -341,11 +335,7 @@ public class MainActivity extends AppCompatActivity implements EipSetupListener, // TODO CATCH ME IF YOU CAN - WHAT DO WE WANT TO DO? break; case INCORRECTLY_UPDATED_INVALID_VPN_CERTIFICATE: - if (LeapSRPSession.loggedIn() || provider.allowsAnonymous()) { showMainActivityErrorDialog(getString(downloading_vpn_certificate_failed)); - } else { - askUserToLogIn(getString(vpn_certificate_user_message)); - } break; case TOR_TIMEOUT: case TOR_EXCEPTION: @@ -429,20 +419,11 @@ public class MainActivity extends AppCompatActivity implements EipSetupListener, try { JSONObject errorJson = new JSONObject(errorJsonString); return ERROR_INVALID_VPN_CERTIFICATE.toString().equals(errorJson.getString(ERRORID)) && - !LeapSRPSession.loggedIn() && + provider.allowsRegistered() && !provider.allowsAnonymous(); } catch (JSONException e) { e.printStackTrace(); } return false; } - - private void askUserToLogIn(String userMessage) { - Intent intent = new Intent(this, LoginActivity.class); - intent.putExtra(PROVIDER_KEY, provider); - if (userMessage != null) { - intent.putExtra(USER_MESSAGE, userMessage); - } - startActivityForResult(intent, REQUEST_CODE_LOG_IN); - } } diff --git a/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java b/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java index 19f03dee..21fc81e4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/StartActivity.java @@ -24,7 +24,6 @@ import static se.leap.bitmaskclient.base.models.Constants.EXTRA_MOTD_MSG; import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_EIP_DEFINITION; import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY; import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_CONFIGURE_LEAP; -import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask; import static se.leap.bitmaskclient.base.utils.PreferenceHelper.storeProviderInPreferences; import android.app.Activity; @@ -52,7 +51,6 @@ import se.leap.bitmaskclient.base.models.ProviderObservable; import se.leap.bitmaskclient.base.utils.DateHelper; import se.leap.bitmaskclient.base.utils.PreferenceHelper; import se.leap.bitmaskclient.eip.EipCommand; -import se.leap.bitmaskclient.providersetup.activities.CustomProviderSetupActivity; import se.leap.bitmaskclient.providersetup.activities.SetupActivity; /** diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/AboutFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/AboutFragment.java index e92aa703..275dc1c4 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/AboutFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/AboutFragment.java @@ -1,5 +1,9 @@ package se.leap.bitmaskclient.base.fragments; +import static android.view.View.VISIBLE; +import static se.leap.bitmaskclient.R.string.about_fragment_title; +import static se.leap.bitmaskclient.base.utils.ViewHelper.setActionBarSubtitle; + import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; @@ -7,42 +11,24 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import androidx.appcompat.widget.AppCompatTextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; import se.leap.bitmaskclient.BuildConfig; import se.leap.bitmaskclient.R; - -import static android.view.View.VISIBLE; -import static se.leap.bitmaskclient.R.string.about_fragment_title; -import static se.leap.bitmaskclient.base.utils.ViewHelper.setActionBarSubtitle; +import se.leap.bitmaskclient.databinding.FAboutBinding; public class AboutFragment extends Fragment { final public static String TAG = AboutFragment.class.getSimpleName(); final public static int VIEWED = 0; - private Unbinder unbinder; - - @BindView(R.id.version) - AppCompatTextView versionTextView; - - @BindView(R.id.terms_of_service) - AppCompatTextView termsOfService; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.f_about, container, false); - unbinder = ButterKnife.bind(this, view); + FAboutBinding binding = FAboutBinding.inflate(inflater); setActionBarSubtitle(this, about_fragment_title); - return view; - } - @Override - public void onStart() { - super.onStart(); String version; String name = "Bitmask"; try { @@ -54,18 +40,13 @@ public class AboutFragment extends Fragment { version = "error fetching version"; } - versionTextView.setText(getString(R.string.version_info, name, version)); + binding.version.setText(getString(R.string.version_info, name, version)); if (BuildConfig.FLAVOR_branding.equals("custom") && hasTermsOfServiceResource()) { - termsOfService.setText(getString(getTermsOfServiceResource())); - termsOfService.setVisibility(VISIBLE); + binding.termsOfService.setText(getString(getTermsOfServiceResource())); + binding.termsOfService.setVisibility(VISIBLE); } - } - - @Override - public void onDestroyView() { - super.onDestroyView(); - unbinder.unbind(); + return binding.getRoot(); } private boolean hasTermsOfServiceResource() { diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/AlwaysOnDialog.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/AlwaysOnDialog.java index e68ba170..faa9950b 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/AlwaysOnDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/AlwaysOnDialog.java @@ -1,26 +1,20 @@ package se.leap.bitmaskclient.base.fragments; +import static se.leap.bitmaskclient.base.utils.PreferenceHelper.saveShowAlwaysOnDialog; + import android.app.Dialog; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; -import android.widget.CheckBox; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatDialogFragment; -import androidx.appcompat.widget.AppCompatTextView; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.base.views.IconTextView; - -import static se.leap.bitmaskclient.base.utils.PreferenceHelper.saveShowAlwaysOnDialog; +import se.leap.bitmaskclient.databinding.DCheckboxConfirmBinding; /** @@ -33,41 +27,24 @@ public class AlwaysOnDialog extends AppCompatDialogFragment { public final static String TAG = AlwaysOnDialog.class.getName(); - @BindView(R.id.do_not_show_again) - CheckBox doNotShowAgainCheckBox; - - @BindView(R.id.user_message) - IconTextView userMessage; - - @BindView(R.id.block_vpn_user_message) - AppCompatTextView blockVpnUserMessage; - - private Unbinder unbinder; - - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + LayoutInflater inflater = getActivity().getLayoutInflater(); - View view = inflater.inflate(R.layout.d_checkbox_confirm, null); - unbinder = ButterKnife.bind(this, view); + DCheckboxConfirmBinding binding = DCheckboxConfirmBinding.inflate(inflater); - userMessage.setIcon(R.drawable.ic_settings); - userMessage.setText(getString(R.string.always_on_vpn_user_message)); + binding.userMessage.setIcon(R.drawable.ic_settings); + binding.userMessage.setText(getString(R.string.always_on_vpn_user_message)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - blockVpnUserMessage.setVisibility(View.VISIBLE); + binding.blockVpnUserMessage.setVisibility(View.VISIBLE); } - builder.setView(view) + builder.setView(binding.getRoot()) .setPositiveButton(android.R.string.ok, (dialog, id) -> { - if (doNotShowAgainCheckBox.isChecked()) { + if (binding.doNotShowAgain.isChecked()) { saveShowAlwaysOnDialog(false); } Intent intent = new Intent("android.net.vpn.SETTINGS"); @@ -78,9 +55,4 @@ public class AlwaysOnDialog extends AppCompatDialogFragment { return builder.create(); } - @Override - public void onDestroyView() { - super.onDestroyView(); - unbinder.unbind(); - } } diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/DonationReminderDialog.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/DonationReminderDialog.java index 08346791..6a0a63c5 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/DonationReminderDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/DonationReminderDialog.java @@ -1,5 +1,10 @@ package se.leap.bitmaskclient.base.fragments; +import static se.leap.bitmaskclient.base.models.Constants.DONATION_REMINDER_DURATION; +import static se.leap.bitmaskclient.base.models.Constants.DONATION_URL; +import static se.leap.bitmaskclient.base.models.Constants.ENABLE_DONATION; +import static se.leap.bitmaskclient.base.models.Constants.ENABLE_DONATION_REMINDER; + import android.app.Dialog; import android.content.ActivityNotFoundException; import android.content.Context; @@ -8,59 +13,32 @@ import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; -import android.view.View; -import android.widget.Button; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatDialogFragment; import java.text.ParseException; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; -import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.base.utils.DateHelper; import se.leap.bitmaskclient.base.utils.PreferenceHelper; - -import static se.leap.bitmaskclient.base.models.Constants.DONATION_REMINDER_DURATION; -import static se.leap.bitmaskclient.base.models.Constants.DONATION_URL; -import static se.leap.bitmaskclient.base.models.Constants.ENABLE_DONATION; -import static se.leap.bitmaskclient.base.models.Constants.ENABLE_DONATION_REMINDER; -import static se.leap.bitmaskclient.base.models.Constants.FIRST_TIME_USER_DATE; -import static se.leap.bitmaskclient.base.models.Constants.LAST_DONATION_REMINDER_DATE; +import se.leap.bitmaskclient.databinding.DonationReminderDialogBinding; public class DonationReminderDialog extends AppCompatDialogFragment { public final static String TAG = DonationReminderDialog.class.getName(); private static boolean isShown = false; - @BindView(R.id.btnDonate) - Button btnDonate; - - @BindView(R.id.btnLater) - Button btnLater; - - private Unbinder unbinder; - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); - View view = inflater.inflate(R.layout.donation_reminder_dialog, null); - unbinder = ButterKnife.bind(this, view); + DonationReminderDialogBinding binding = DonationReminderDialogBinding.inflate(inflater); isShown = true; - builder.setView(view); - btnDonate.setOnClickListener(v -> { + builder.setView(binding.getRoot()); + binding.btnDonate.setOnClickListener(v -> { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(DONATION_URL)); try { startActivity(browserIntent); @@ -70,7 +48,7 @@ public class DonationReminderDialog extends AppCompatDialogFragment { PreferenceHelper.lastDonationReminderDate(DateHelper.getCurrentDateString()); dismiss(); }); - btnLater.setOnClickListener(v -> { + binding.btnLater.setOnClickListener(v -> { PreferenceHelper.lastDonationReminderDate(DateHelper.getCurrentDateString()); dismiss(); }); @@ -78,12 +56,6 @@ public class DonationReminderDialog extends AppCompatDialogFragment { return builder.create(); } - @Override - public void onDestroyView() { - super.onDestroyView(); - unbinder.unbind(); - } - public static boolean isCallable(Context context) { if (isShown) { return false; @@ -97,7 +69,6 @@ public class DonationReminderDialog extends AppCompatDialogFragment { Log.e(TAG, "context is null!"); return false; } - String firstTimeUserDate = PreferenceHelper.getFirstTimeUserDate(); if (firstTimeUserDate == null) { PreferenceHelper.firstTimeUserDate(DateHelper.getCurrentDateString()); diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java index 670cdfd8..c500b55b 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/EipFragment.java @@ -16,21 +16,16 @@ */ package se.leap.bitmaskclient.base.fragments; -import static se.leap.bitmaskclient.R.string.vpn_certificate_user_message; import static se.leap.bitmaskclient.base.models.Constants.ASK_TO_CANCEL_VPN; import static se.leap.bitmaskclient.base.models.Constants.EIP_ACTION_START; import static se.leap.bitmaskclient.base.models.Constants.EIP_EARLY_ROUTES; import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY; -import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_CONFIGURE_LEAP; -import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_LOG_IN; import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_SWITCH_PROVIDER; -import static se.leap.bitmaskclient.base.utils.ConfigHelper.isDefaultBitmask; import static se.leap.bitmaskclient.base.utils.PreferenceHelper.getPreferredCity; import static se.leap.bitmaskclient.eip.EipSetupObserver.reconnectingWithDifferentGateway; import static se.leap.bitmaskclient.eip.GatewaysManager.Load.UNKNOWN; import static se.leap.bitmaskclient.providersetup.ProviderAPI.DOWNLOAD_GEOIP_JSON; import static se.leap.bitmaskclient.providersetup.ProviderAPI.UPDATE_INVALID_VPN_CERTIFICATE; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.USER_MESSAGE; import android.app.Activity; import android.content.Context; @@ -46,6 +41,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; import androidx.annotation.ColorRes; import androidx.annotation.DrawableRes; @@ -80,10 +76,7 @@ import se.leap.bitmaskclient.eip.EipCommand; import se.leap.bitmaskclient.eip.EipStatus; import se.leap.bitmaskclient.eip.GatewaysManager; import se.leap.bitmaskclient.providersetup.ProviderAPICommand; -import se.leap.bitmaskclient.providersetup.ProviderListActivity; -import se.leap.bitmaskclient.providersetup.activities.CustomProviderSetupActivity; -import se.leap.bitmaskclient.providersetup.activities.LoginActivity; -import se.leap.bitmaskclient.providersetup.models.LeapSRPSession; +import se.leap.bitmaskclient.providersetup.activities.SetupActivity; import se.leap.bitmaskclient.tor.TorServiceCommand; import se.leap.bitmaskclient.tor.TorStatusObservable; @@ -136,14 +129,7 @@ public class EipFragment extends Fragment implements Observer { } private void handleNoProvider(Activity activity) { - if (isDefaultBitmask()) { - activity.startActivityForResult(new Intent(activity, ProviderListActivity.class), REQUEST_CODE_SWITCH_PROVIDER); - } else { - Log.e(TAG, "no provider given - try to reconfigure custom provider"); - startActivityForResult(new Intent(activity, CustomProviderSetupActivity.class), REQUEST_CODE_CONFIGURE_LEAP); - - } - + activity.startActivityForResult(new Intent(activity, SetupActivity.class), REQUEST_CODE_SWITCH_PROVIDER); } @Override @@ -283,11 +269,10 @@ public class EipFragment extends Fragment implements Observer { if (canStartEIP()) { startEipFromScratch(); - } else if (canLogInToStartEIP()) { - askUserToLogIn(getString(vpn_certificate_user_message)); - } else { - // provider has no VpnCertificate but user is logged in + } else if (provider.allowsAnonymous()){ updateInvalidVpnCertificate(); + } else { + Toast.makeText(getContext(), R.string.config_error_found, Toast.LENGTH_LONG).show(); } } @@ -297,12 +282,6 @@ public class EipFragment extends Fragment implements Observer { return (isAllowedAnon || certificateExists) && !eipStatus.isConnected() && !eipStatus.isConnecting(); } - private boolean canLogInToStartEIP() { - boolean isAllowedRegistered = provider.allowsRegistered(); - boolean isLoggedIn = LeapSRPSession.loggedIn(); - return isAllowedRegistered && !isLoggedIn && !eipStatus.isConnecting() && !eipStatus.isConnected(); - } - private void handleSwitchOff() { if (eipStatus.isVPNRunningWithoutNetwork() || eipStatus.isConnecting() || eipStatus.isUpdatingVpnCert()) { askPendingStartCancellation(); @@ -562,7 +541,6 @@ public class EipFragment extends Fragment implements Observer { // eat me } - stateView.setImageResource(drawableRes); stateView.setTag(drawableRes); if (stateView.getDrawable() instanceof Animatable) { @@ -592,20 +570,6 @@ public class EipFragment extends Fragment implements Observer { ProviderAPICommand.execute(getContext(), UPDATE_INVALID_VPN_CERTIFICATE, provider); } - private void askUserToLogIn(String userMessage) { - Intent intent = new Intent(getContext(), LoginActivity.class); - intent.putExtra(PROVIDER_KEY, provider); - - if(userMessage != null) { - intent.putExtra(USER_MESSAGE, userMessage); - } - - Activity activity = getActivity(); - if (activity != null) { - activity.startActivityForResult(intent, REQUEST_CODE_LOG_IN); - } - } - public void showDonationReminderDialog() { try { FragmentTransaction fragmentTransaction = new FragmentManagerEnhanced( diff --git a/app/src/main/java/se/leap/bitmaskclient/base/fragments/TetheringDialog.java b/app/src/main/java/se/leap/bitmaskclient/base/fragments/TetheringDialog.java index eb9d149f..588daa3f 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/fragments/TetheringDialog.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/fragments/TetheringDialog.java @@ -19,7 +19,6 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatDialogFragment; -import androidx.appcompat.widget.AppCompatTextView; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -28,13 +27,11 @@ import java.util.Observer; import java.util.regex.Matcher; import java.util.regex.Pattern; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; import de.blinkt.openvpn.core.VpnStatus; import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.base.utils.PreferenceHelper; import se.leap.bitmaskclient.base.views.IconCheckboxEntry; +import se.leap.bitmaskclient.databinding.DListSelectionBinding; import se.leap.bitmaskclient.firewall.FirewallManager; import se.leap.bitmaskclient.tethering.TetheringObservable; @@ -59,17 +56,8 @@ public class TetheringDialog extends AppCompatDialogFragment implements Observer public final static String TAG = TetheringDialog.class.getName(); - @BindView(R.id.tvTitle) - AppCompatTextView title; - - @BindView(R.id.user_message) - AppCompatTextView userMessage; - - @BindView(R.id.selection_list_view) - RecyclerView selectionListView; DialogListAdapter adapter; private DialogListAdapter.ViewModel[] dataset; - private Unbinder unbinder; public static class DialogListAdapter extends RecyclerView.Adapter<DialogListAdapter.ViewHolder> { @@ -139,21 +127,19 @@ public class TetheringDialog extends AppCompatDialogFragment implements Observer public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); - View view = inflater.inflate(R.layout.d_list_selection, null); - unbinder = ButterKnife.bind(this, view); + DListSelectionBinding binding = DListSelectionBinding.inflate(inflater); - title.setText(R.string.tethering); - userMessage.setMovementMethod(LinkMovementMethod.getInstance()); - userMessage.setLinkTextColor(getContext().getResources().getColor(R.color.colorPrimary)); - userMessage.setText(createUserMessage()); + binding.tvTitle.setText(R.string.tethering); + binding.userMessage.setMovementMethod(LinkMovementMethod.getInstance()); + binding.userMessage.setLinkTextColor(getContext().getResources().getColor(R.color.colorPrimary)); + binding.userMessage.setText(createUserMessage()); initDataset(); adapter = new DialogListAdapter(dataset, this::onItemClick); - selectionListView.setAdapter(adapter); - selectionListView.setLayoutManager(new LinearLayoutManager(getActivity())); - + binding.selectionListView.setAdapter(adapter); + binding.selectionListView.setLayoutManager(new LinearLayoutManager(getActivity())); - builder.setView(view) + builder.setView(binding.getRoot()) .setPositiveButton(android.R.string.ok, (dialog, id) -> { PreferenceHelper.allowWifiTethering(dataset[0].checked); PreferenceHelper.allowUsbTethering(dataset[1].checked); @@ -190,12 +176,6 @@ public class TetheringDialog extends AppCompatDialogFragment implements Observer TetheringObservable.getInstance().deleteObserver(this); } - @Override - public void onDestroyView() { - super.onDestroyView(); - unbinder.unbind(); - } - public void onItemClick(DialogListAdapter.ViewModel item) { } diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/IconCheckboxEntry.java b/app/src/main/java/se/leap/bitmaskclient/base/views/IconCheckboxEntry.java index 0957712b..ee1a6903 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/views/IconCheckboxEntry.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/views/IconCheckboxEntry.java @@ -5,31 +5,20 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.view.LayoutInflater; -import android.view.View; import android.widget.LinearLayout; import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatImageView; -import androidx.appcompat.widget.AppCompatTextView; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; -import butterknife.BindView; -import butterknife.ButterKnife; import se.leap.bitmaskclient.R; import se.leap.bitmaskclient.base.fragments.TetheringDialog; +import se.leap.bitmaskclient.databinding.VIconSelectTextListItemBinding; public class IconCheckboxEntry extends LinearLayout { - @BindView(android.R.id.text1) - AppCompatTextView textView; - - @BindView(R.id.material_icon) - AppCompatImageView iconView; - - @BindView(R.id.checked_icon) - AppCompatImageView checkedIcon; + VIconSelectTextListItemBinding binding; public IconCheckboxEntry(Context context) { super(context); @@ -55,14 +44,13 @@ public class IconCheckboxEntry extends LinearLayout { void initLayout(Context context, AttributeSet attrs) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View rootview = inflater.inflate(R.layout.v_icon_select_text_list_item, this, true); - ButterKnife.bind(this, rootview); + binding = VIconSelectTextListItemBinding.inflate(inflater, this, true); } public void bind(TetheringDialog.DialogListAdapter.ViewModel model) { this.setEnabled(model.enabled); - textView.setText(model.text); - textView.setEnabled(model.enabled); + binding.text1.setText(model.text); + binding.text1.setEnabled(model.enabled); Drawable checkIcon = DrawableCompat.wrap(getResources().getDrawable(R.drawable.ic_check_bold)).mutate(); if (model.enabled) { @@ -71,14 +59,14 @@ public class IconCheckboxEntry extends LinearLayout { DrawableCompat.setTint(checkIcon, ContextCompat.getColor(getContext(), R.color.colorDisabled)); } - iconView.setImageDrawable(model.image); - checkedIcon.setImageDrawable(checkIcon); + binding.materialIcon.setImageDrawable(model.image); + binding.checkedIcon.setImageDrawable(checkIcon); setChecked(model.checked); } public void setChecked(boolean checked) { - checkedIcon.setVisibility(checked ? VISIBLE : GONE); - checkedIcon.setContentDescription(checked ? "selected" : "unselected"); + binding.checkedIcon.setVisibility(checked ? VISIBLE : GONE); + binding.checkedIcon.setContentDescription(checked ? "selected" : "unselected"); } } diff --git a/app/src/main/java/se/leap/bitmaskclient/base/views/ProviderHeaderView.java b/app/src/main/java/se/leap/bitmaskclient/base/views/ProviderHeaderView.java deleted file mode 100644 index 811a54a2..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/base/views/ProviderHeaderView.java +++ /dev/null @@ -1,109 +0,0 @@ -package se.leap.bitmaskclient.base.views; - -import android.content.Context; -import androidx.annotation.DrawableRes; -import androidx.annotation.RequiresApi; -import androidx.annotation.StringRes; -import androidx.appcompat.widget.AppCompatImageView; -import androidx.appcompat.widget.AppCompatTextView; -import android.util.AttributeSet; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.RelativeLayout; - -import se.leap.bitmaskclient.R; - -import static se.leap.bitmaskclient.base.utils.ViewHelper.convertDimensionToPx; - -/** - * Created by cyberta on 29.06.18. - */ - -public class ProviderHeaderView extends RelativeLayout { - private int stdPadding; - private int compactPadding; - private int stdImageSize; - private int compactImageSize; - - AppCompatImageView providerHeaderLogo; - AppCompatTextView providerHeaderText; - - public ProviderHeaderView(Context context) { - super(context); - initLayout(context); - } - - public ProviderHeaderView(Context context, AttributeSet attrs) { - super(context, attrs); - initLayout(context); - } - - public ProviderHeaderView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - initLayout(context); - } - - @RequiresApi(21) - public ProviderHeaderView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - initLayout(context); - } - - - void initLayout(Context context) { - LayoutInflater inflater = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View rootview = inflater.inflate(R.layout.v_provider_header, this, true); - providerHeaderLogo = rootview.findViewById(R.id.provider_header_logo); - providerHeaderText = rootview.findViewById(R.id.provider_header_text); - - stdPadding = convertDimensionToPx(context, R.dimen.stdpadding); - compactPadding = convertDimensionToPx(context, R.dimen.compact_padding); - stdImageSize = convertDimensionToPx(context, R.dimen.bitmask_logo); - compactImageSize = convertDimensionToPx(context, R.dimen.bitmask_logo_compact); - } - - public void setTitle(String title) { - providerHeaderText.setText(title); - } - - public void setTitle(@StringRes int stringRes) { - providerHeaderText.setText(stringRes); - } - - public void setLogo(@DrawableRes int drawableRes) { - providerHeaderLogo.setImageResource(drawableRes); - } - - public void showCompactLayout() { - LayoutParams logoLayoutParams = (LayoutParams) providerHeaderLogo.getLayoutParams(); - logoLayoutParams.width = compactImageSize; - logoLayoutParams.height = compactImageSize; - providerHeaderLogo.setLayoutParams(logoLayoutParams); - - LayoutParams textLayoutParams = (LayoutParams) providerHeaderText.getLayoutParams(); - textLayoutParams.addRule(RIGHT_OF, R.id.provider_header_logo); - textLayoutParams.addRule(BELOW, 0); - textLayoutParams.addRule(ALIGN_TOP, R.id.provider_header_logo); - textLayoutParams.setMargins(compactPadding, compactPadding, compactPadding, compactPadding); - - providerHeaderText.setLayoutParams(textLayoutParams); - providerHeaderText.setMaxLines(2); - } - - public void showStandardLayout() { - LayoutParams logoLayoutParams = (LayoutParams) providerHeaderLogo.getLayoutParams(); - logoLayoutParams.width = stdImageSize; - logoLayoutParams.height = stdImageSize; - providerHeaderLogo.setLayoutParams(logoLayoutParams); - - LayoutParams textLayoutParams = (LayoutParams) providerHeaderText.getLayoutParams(); - textLayoutParams.addRule(RIGHT_OF, 0); - textLayoutParams.addRule(BELOW, R.id.provider_header_logo); - textLayoutParams.addRule(ALIGN_TOP, 0); - textLayoutParams.setMargins(stdPadding, stdPadding, stdPadding, stdPadding); - providerHeaderText.setLayoutParams(textLayoutParams); - providerHeaderText.setMaxLines(1); - } - -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiSetupBroadcastReceiver.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiSetupBroadcastReceiver.java index 4b7d22fc..ee39499b 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiSetupBroadcastReceiver.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderApiSetupBroadcastReceiver.java @@ -16,6 +16,8 @@ */ package se.leap.bitmaskclient.providersetup; +import static android.app.Activity.RESULT_CANCELED; + import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -27,7 +29,6 @@ import java.lang.ref.WeakReference; import se.leap.bitmaskclient.base.models.Constants; import se.leap.bitmaskclient.base.models.Provider; import se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState; -import se.leap.bitmaskclient.providersetup.activities.ProviderListBaseActivity; /** * Broadcast receiver that handles callback intents of ProviderApi during provider setup. @@ -38,6 +39,7 @@ import se.leap.bitmaskclient.providersetup.activities.ProviderListBaseActivity; */ public class ProviderApiSetupBroadcastReceiver extends BroadcastReceiver { + private static final String TAG = ProviderApiSetupBroadcastReceiver.class.getSimpleName(); private final WeakReference<ProviderSetupInterface> setupInterfaceRef; public ProviderApiSetupBroadcastReceiver(ProviderSetupInterface setupInterface) { @@ -46,7 +48,7 @@ public class ProviderApiSetupBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - Log.d(ProviderListBaseActivity.TAG, "received Broadcast"); + Log.d(TAG, "received Broadcast"); ProviderSetupInterface setupInterface = setupInterfaceRef.get(); String action = intent.getAction(); if (action == null || !action.equalsIgnoreCase(Constants.BROADCAST_PROVIDER_API_EVENT) || setupInterface == null) { @@ -55,8 +57,8 @@ public class ProviderApiSetupBroadcastReceiver extends BroadcastReceiver { if (setupInterface.getConfigState() != null && setupInterface.getConfigState() == ProviderConfigState.SETTING_UP_PROVIDER) { - int resultCode = intent.getIntExtra(Constants.BROADCAST_RESULT_CODE, ProviderListBaseActivity.RESULT_CANCELED); - Log.d(ProviderListBaseActivity.TAG, "Broadcast resultCode: " + resultCode); + int resultCode = intent.getIntExtra(Constants.BROADCAST_RESULT_CODE, RESULT_CANCELED); + Log.d(TAG, "Broadcast resultCode: " + resultCode); Bundle resultData = intent.getParcelableExtra(Constants.BROADCAST_RESULT_KEY); Provider handledProvider = resultData.getParcelable(Constants.PROVIDER_KEY); diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderListAdapter.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderListAdapter.java deleted file mode 100644 index 76ee33f2..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderListAdapter.java +++ /dev/null @@ -1,21 +0,0 @@ -package se.leap.bitmaskclient.providersetup; - -import android.view.LayoutInflater; - -import com.pedrogomez.renderers.AdapteeCollection; -import com.pedrogomez.renderers.RendererAdapter; -import com.pedrogomez.renderers.RendererBuilder; - -import se.leap.bitmaskclient.base.models.Provider; - -public class ProviderListAdapter extends RendererAdapter<Provider> { - public ProviderListAdapter(LayoutInflater layoutInflater, RendererBuilder rendererBuilder, - AdapteeCollection<Provider> collection) { - super(layoutInflater, rendererBuilder, collection); - } - - public void saveProviders() { - ProviderManager provider_manager = (ProviderManager) getCollection(); - provider_manager.saveCustomProvidersToFile(); - } -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderManager.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderManager.java index b46072ff..38198f89 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderManager.java @@ -19,8 +19,6 @@ import android.content.res.AssetManager; import androidx.annotation.VisibleForTesting; -import com.pedrogomez.renderers.AdapteeCollection; - import org.json.JSONObject; import java.io.File; @@ -39,7 +37,7 @@ import se.leap.bitmaskclient.base.models.Provider; /** * Created by parmegv on 4/12/14. */ -public class ProviderManager implements AdapteeCollection<Provider> { +public class ProviderManager { private final AssetManager assetsManager; private File externalFilesDir; @@ -165,12 +163,10 @@ public class ProviderManager implements AdapteeCollection<Provider> { return allProviders; } - @Override public int size() { return providers().size(); } - @Override public Provider get(int index) { Iterator<Provider> iterator = providers().iterator(); while (iterator.hasNext() && index > 0) { @@ -180,7 +176,6 @@ public class ProviderManager implements AdapteeCollection<Provider> { return iterator.next(); } - @Override public boolean add(Provider element) { return element != null && !defaultProviderURLs.contains(element.getMainUrl().toString()) && @@ -188,14 +183,12 @@ public class ProviderManager implements AdapteeCollection<Provider> { customProviderURLs.add(element.getMainUrl().toString()); } - @Override public boolean remove(Object element) { return element instanceof Provider && customProviders.remove(element) && customProviderURLs.remove(((Provider) element).getMainUrl().toString()); } - @Override public boolean addAll(Collection<? extends Provider> elements) { Iterator iterator = elements.iterator(); boolean addedAll = true; @@ -208,7 +201,6 @@ public class ProviderManager implements AdapteeCollection<Provider> { return addedAll; } - @Override public boolean removeAll(Collection<?> elements) { Iterator iterator = elements.iterator(); boolean removedAll = true; @@ -226,7 +218,6 @@ public class ProviderManager implements AdapteeCollection<Provider> { return removedAll; } - @Override public void clear() { defaultProviders.clear(); customProviders.clear(); diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderRenderer.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderRenderer.java deleted file mode 100644 index 8aba4941..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderRenderer.java +++ /dev/null @@ -1,61 +0,0 @@ -package se.leap.bitmaskclient.providersetup; - -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import androidx.appcompat.widget.AppCompatTextView; - -import com.pedrogomez.renderers.Renderer; - -import butterknife.BindView; -import butterknife.ButterKnife; -import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.base.models.Provider; - -/** - * Created by parmegv on 4/12/14. - */ -public class ProviderRenderer extends Renderer<Provider> { - private final Context context; - - @BindView(R.id.provider_name) - AppCompatTextView name; - @BindView(R.id.provider_domain) - AppCompatTextView domain; - - public ProviderRenderer(Context context) { - this.context = context; - } - - @Override - protected View inflate(LayoutInflater inflater, ViewGroup parent) { - View view = inflater.inflate(R.layout.v_provider_list_item, parent, false); - ButterKnife.bind(this, view); - return view; - } - - @Override - protected void setUpView(View rootView) { - /* - * Empty implementation substituted with the usage of ButterKnife library by Jake Wharton. - */ - } - - @Override - protected void hookListeners(View rootView) { - //Empty - } - - @Override - public void render() { - Provider provider = getContent(); - if (!provider.isDefault()) { - name.setText(provider.getName()); - domain.setText(provider.getDomain()); - } else { - domain.setText(R.string.add_provider); - } - } -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderRendererBuilder.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderRendererBuilder.java deleted file mode 100644 index 7d2b4742..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/ProviderRendererBuilder.java +++ /dev/null @@ -1,21 +0,0 @@ -package se.leap.bitmaskclient.providersetup; - -import com.pedrogomez.renderers.*; - -import java.util.*; - -import se.leap.bitmaskclient.base.models.Provider; - -/** - * Created by parmegv on 4/12/14. - */ -public class ProviderRendererBuilder extends RendererBuilder<Provider> { - public ProviderRendererBuilder(Collection<Renderer<Provider>> prototypes) { - super(prototypes); - } - - @Override - protected Class getPrototypeClass(Provider content) { - return ProviderRenderer.class; - } -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/TorLogAdapter.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/TorLogAdapter.java index 3df0fd94..816d4690 100644 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/TorLogAdapter.java +++ b/app/src/main/java/se/leap/bitmaskclient/providersetup/TorLogAdapter.java @@ -11,7 +11,6 @@ import androidx.recyclerview.widget.RecyclerView; import java.util.List; import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.providersetup.activities.ConfigWizardBaseActivity; public class TorLogAdapter extends RecyclerView.Adapter<TorLogAdapter.ViewHolder> { private List<String> values; diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/AbstractProviderDetailActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/AbstractProviderDetailActivity.java deleted file mode 100644 index 66999580..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/AbstractProviderDetailActivity.java +++ /dev/null @@ -1,108 +0,0 @@ -package se.leap.bitmaskclient.providersetup.activities; - -import android.content.Intent; -import android.os.Bundle; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.AppCompatTextView; -import android.util.Log; -import android.widget.ArrayAdapter; -import android.widget.ListView; -import android.widget.TextView; - -import java.util.ArrayList; - - -import butterknife.BindView; -import se.leap.bitmaskclient.base.models.Provider; -import se.leap.bitmaskclient.R; - -import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY; -import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_CONFIGURE_LEAP; - -public abstract class AbstractProviderDetailActivity extends ConfigWizardBaseActivity { - - final public static String TAG = "providerDetailActivity"; - - @BindView(R.id.provider_detail_description) - AppCompatTextView description; - - @BindView(R.id.provider_detail_options) - ListView options; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - provider = getIntent().getParcelableExtra(PROVIDER_KEY); - setContentView(R.layout.a_provider_detail); - - if (provider == null) { - return; - } - - setProviderHeaderText(provider.getName()); - description.setText(provider.getDescription()); - - // Show only the options allowed by the provider - ArrayList<String> optionsList = new ArrayList<>(); - if (provider.allowsRegistered()) { - optionsList.add(getString(R.string.login_to_profile)); - optionsList.add(getString(R.string.create_profile)); - if (provider.allowsAnonymous()) { - optionsList.add(getString(R.string.use_anonymously_button)); - } - } else { - onAnonymouslySelected(); - } - - options.setAdapter(new ArrayAdapter<>( - this, - R.layout.v_single_list_item, - android.R.id.text1, - optionsList.toArray(new String[optionsList.size()]) - )); - options.setOnItemClickListener((parent, view, position, id) -> { - String text = ((AppCompatTextView) view).getText().toString(); - Intent intent; - if (text.equals(getString(R.string.login_to_profile))) { - Log.d(TAG, "login selected"); - intent = new Intent(getApplicationContext(), LoginActivity.class); - } else if (text.equals(getString(R.string.create_profile))) { - Log.d(TAG, "signup selected"); - intent = new Intent(getApplicationContext(), SignupActivity.class); - } else { - onAnonymouslySelected(); - return; - } - intent.putExtra(PROVIDER_KEY, provider); - intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); - startActivityForResult(intent, REQUEST_CODE_CONFIGURE_LEAP); - }); - } - - @Override - protected void onNewIntent(Intent intent) { - super.onNewIntent(intent); - provider = intent.getParcelableExtra(PROVIDER_KEY); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == REQUEST_CODE_CONFIGURE_LEAP) { - if (resultCode == RESULT_OK) { - setResult(resultCode, data); - finish(); - } - } - } - - private void onAnonymouslySelected() { - Intent intent; - Log.d(TAG, "use anonymously selected"); - intent = new Intent(); - intent.putExtra(Provider.KEY, provider); - setResult(RESULT_OK, intent); - finish(); - } - -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/AddProviderBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/AddProviderBaseActivity.java deleted file mode 100644 index 193c1d59..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/AddProviderBaseActivity.java +++ /dev/null @@ -1,126 +0,0 @@ -package se.leap.bitmaskclient.providersetup.activities; - -import android.content.Intent; -import android.os.Bundle; -import android.text.Editable; -import android.text.TextWatcher; -import android.view.View; -import android.widget.Button; - -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; - -import butterknife.BindView; -import se.leap.bitmaskclient.R; - -import static se.leap.bitmaskclient.providersetup.activities.ProviderListBaseActivity.EXTRAS_KEY_INVALID_URL; - -/** - * Created by cyberta on 30.06.18. - */ - -public abstract class AddProviderBaseActivity extends ConfigWizardBaseActivity { - - final public static String EXTRAS_KEY_NEW_URL = "NEW_URL"; - - @BindView(R.id.text_uri_error) - TextInputLayout urlError; - - @BindView(R.id.text_uri) - TextInputEditText editUrl; - - @BindView(R.id.button_cancel) - Button cancelButton; - - @BindView(R.id.button_save) - Button saveButton; - - - protected void init() { - Bundle extras = this.getIntent().getExtras(); - if (extras != null && extras.containsKey(EXTRAS_KEY_INVALID_URL)) { - editUrl.setText(extras.getString(EXTRAS_KEY_INVALID_URL)); - saveButton.setEnabled(true); - } - - setupSaveButton(); - setupCancelButton(); - setUpListeners(); - setUpInitialUI(); - } - - public abstract void setupSaveButton(); - - private void setupCancelButton() { - cancelButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - finish(); - } - }); - } - - private void setUpInitialUI() { - setProviderHeaderText(R.string.add_provider); - hideProgressBar(); - } - - protected void saveProvider() { - String entered_url = getURL(); - if (validURL(entered_url)) { - Intent intent = this.getIntent(); - intent.putExtra(EXTRAS_KEY_NEW_URL, entered_url); - setResult(RESULT_OK, intent); - finish(); - } else { - editUrl.setText(""); - urlError.setError(getString(R.string.not_valid_url_entered)); - } - } - - private void setUpListeners() { - - editUrl.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public void afterTextChanged(Editable s) { - if (!validURL(getURL())) { - urlError.setError(getString(R.string.not_valid_url_entered)); - saveButton.setEnabled(false); - - } else { - urlError.setError(null); - saveButton.setEnabled(true); - } - } - }); - } - - private String getURL() { - String entered_url = editUrl.getText().toString().trim(); - if (entered_url.contains("www.")) entered_url = entered_url.replaceFirst("www.", ""); - if (!entered_url.startsWith("https://")) { - if (entered_url.startsWith("http://")) { - entered_url = entered_url.substring("http://".length()); - } - entered_url = "https://".concat(entered_url); - } - return entered_url; - } - - /** - * Checks if the entered url is valid or not. - * - * @param enteredUrl - * @return true if it's not empty nor contains only the protocol. - */ - boolean validURL(String enteredUrl) { - return android.util.Patterns.WEB_URL.matcher(enteredUrl).matches(); - } -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ButterKnifeActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ButterKnifeActivity.java deleted file mode 100644 index c695cc46..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ButterKnifeActivity.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2020 LEAP Encryption Access Project and contributers - * - * 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, see <http://www.gnu.org/licenses/>. - */ -package se.leap.bitmaskclient.providersetup.activities; - -import android.view.View; - -import androidx.appcompat.app.AppCompatActivity; - -import butterknife.ButterKnife; - -/** - * Automatically inject with ButterKnife after calling setContentView - */ - -public abstract class ButterKnifeActivity extends AppCompatActivity { - - @Override - public void setContentView(View view) { - super.setContentView(view); - ButterKnife.bind(this); - } - - @Override - public void setContentView(int layoutResID) { - super.setContentView(layoutResID); - ButterKnife.bind(this); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - } -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ConfigWizardBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ConfigWizardBaseActivity.java deleted file mode 100644 index 1bf66d7d..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ConfigWizardBaseActivity.java +++ /dev/null @@ -1,430 +0,0 @@ -package se.leap.bitmaskclient.providersetup.activities; - -import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; -import static android.view.View.GONE; -import static android.view.View.VISIBLE; -import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE; -import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY; -import static se.leap.bitmaskclient.tor.TorStatusObservable.getBootstrapProgress; -import static se.leap.bitmaskclient.tor.TorStatusObservable.getLastLogs; -import static se.leap.bitmaskclient.tor.TorStatusObservable.getLastSnowflakeLog; -import static se.leap.bitmaskclient.tor.TorStatusObservable.getLastTorLog; -import static se.leap.bitmaskclient.tor.TorStatusObservable.getStringForCurrentStatus; - -import android.graphics.Rect; -import android.os.Build; -import android.os.Bundle; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.widget.LinearLayout; -import android.widget.ProgressBar; -import android.widget.RelativeLayout; - -import androidx.annotation.DrawableRes; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.StringRes; -import androidx.appcompat.widget.AppCompatTextView; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.constraintlayout.widget.Guideline; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; - -import java.util.List; -import java.util.Observable; -import java.util.Observer; - -import butterknife.BindView; -import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.base.models.Provider; -import se.leap.bitmaskclient.base.views.ProviderHeaderView; -import se.leap.bitmaskclient.providersetup.TorLogAdapter; -import se.leap.bitmaskclient.tor.TorStatusObservable; - -/** - * Base Activity for configuration wizard activities - * - * Created by fupduck on 09.01.18. - */ - -public abstract class ConfigWizardBaseActivity extends ButterKnifeActivity implements Observer { - - private static final String TAG = ConfigWizardBaseActivity.class.getName(); - public static final float GUIDE_LINE_COMPACT_DELTA = 0.1f; - - @BindView(R.id.header) - ProviderHeaderView providerHeaderView; - - //Add provider screen has no loading screen - @Nullable - @BindView(R.id.loading_screen) - protected LinearLayout loadingScreen; - - @Nullable - @BindView(R.id.btn_connection_detail) - protected AppCompatTextView connectionDetailBtn; - - @Nullable - @BindView(R.id.connection_detail_header_container) - protected RelativeLayout connectionDetailHeaderContainer; - - @Nullable - @BindView(R.id.connection_details_title) - protected AppCompatTextView connectionDetailsTitle; - - @Nullable - @BindView(R.id.connection_detail_container) - protected RelativeLayout connectionDetailContainer; - - @Nullable - @BindView(R.id.log_container) - protected RelativeLayout logsContainer; - - @Nullable - @BindView(R.id.tor_state) - protected AppCompatTextView torState; - - @Nullable - @BindView(R.id.snowflake_state) - protected AppCompatTextView snowflakeState; - - @Nullable - @BindView(R.id.connection_detail_logs) - protected RecyclerView connectionDetailLogs; - - private TorLogAdapter torLogAdapter; - - @Nullable - @BindView(R.id.progressbar) - protected ProgressBar progressBar; - - @Nullable - @BindView(R.id.progressbar_title) - protected AppCompatTextView progressbarTitle; - - @Nullable - @BindView(R.id.progressbar_description) - protected AppCompatTextView progressbarDescription; - - //Only tablet layouts have guidelines as they are based on a ConstraintLayout - @Nullable - @BindView(R.id.guideline_top) - protected Guideline guideline_top; - - @Nullable - @BindView(R.id.guideline_bottom) - protected Guideline guideline_bottom; - - @BindView(R.id.content) - protected LinearLayout content; - - protected Provider provider; - - protected boolean isCompactLayout = false; - protected boolean isActivityShowing; - - private float defaultGuidelineTopPercentage; - private float defaultGuidelineBottomPercentage; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - provider = getIntent().getParcelableExtra(PROVIDER_KEY); - } - - @Override - public void setContentView(View view) { - super.setContentView(view); - initContentView(); - } - - @Override - public void setContentView(int layoutResID) { - super.setContentView(layoutResID); - initContentView(); - } - - @Override - public void setContentView(View view, ViewGroup.LayoutParams params) { - super.setContentView(view, params); - initContentView(); - } - - private void initContentView() { - if (provider != null) { - setProviderHeaderText(provider.getName()); - } - setDefaultGuidelineValues(); - setGlobalLayoutChangeListener(); - } - - private void setDefaultGuidelineValues() { - if (isTabletLayout()) { - defaultGuidelineTopPercentage = ((ConstraintLayout.LayoutParams) guideline_top.getLayoutParams()).guidePercent; - defaultGuidelineBottomPercentage = ((ConstraintLayout.LayoutParams) guideline_bottom.getLayoutParams()).guidePercent; - } - } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - if (provider != null) { - outState.putParcelable(PROVIDER_KEY, provider); - } - } - - @Override - protected void onPause() { - super.onPause(); - isActivityShowing = false; - TorStatusObservable.getInstance().deleteObserver(this); - } - - @Override - protected void onResume() { - super.onResume(); - isActivityShowing = true; - TorStatusObservable.getInstance().addObserver(this); - setProgressbarDescription(getStringForCurrentStatus(this)); - } - - protected void restoreState(Bundle savedInstanceState) { - if (savedInstanceState != null && savedInstanceState.containsKey(PROVIDER_KEY)) { - provider = savedInstanceState.getParcelable(PROVIDER_KEY); - } - } - - protected void setProviderHeaderLogo(@DrawableRes int providerHeaderLogo) { - providerHeaderView.setLogo(providerHeaderLogo); - } - - protected void setProviderHeaderText(String providerHeaderText) { - providerHeaderView.setTitle(providerHeaderText); - } - - protected void setProviderHeaderText(@StringRes int providerHeaderText) { - providerHeaderView.setTitle(providerHeaderText); - } - - protected void hideConnectionDetails() { - if (loadingScreen == null) { - return; - } - if (connectionDetailContainer.getVisibility() == VISIBLE) { - connectionDetailBtn.setText(R.string.show_connection_details); - } - connectionDetailHeaderContainer.setVisibility(GONE); - connectionDetailContainer.setVisibility(GONE); - logsContainer.setVisibility(GONE); - } - - protected void showConnectionDetails() { - if (loadingScreen == null) { - return; - } - LinearLayoutManager layoutManager = new LinearLayoutManager(this); - connectionDetailLogs.setLayoutManager(layoutManager); - torLogAdapter = new TorLogAdapter(getLastLogs()); - connectionDetailLogs.setAdapter(torLogAdapter); - - connectionDetailLogs.addOnScrollListener(new RecyclerView.OnScrollListener() { - @Override - public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { - super.onScrollStateChanged(recyclerView, newState); - if (newState != SCROLL_STATE_IDLE) { - torLogAdapter.postponeUpdate = true; - } else if (newState == SCROLL_STATE_IDLE && getFirstVisibleItemPosion() == 0) { - torLogAdapter.postponeUpdate = false; - } - } - }); - - snowflakeState.setText(getLastSnowflakeLog()); - torState.setText(getLastTorLog()); - connectionDetailBtn.setOnClickListener(v -> { - if (logsContainer.getVisibility() == VISIBLE) { - logsContainer.setVisibility(GONE); - connectionDetailContainer.setVisibility(GONE); - connectionDetailsTitle.setVisibility(GONE); - connectionDetailBtn.setText(R.string.show_connection_details); - } else { - logsContainer.setVisibility(VISIBLE); - connectionDetailContainer.setVisibility(VISIBLE); - connectionDetailsTitle.setVisibility(VISIBLE); - connectionDetailBtn.setText(R.string.hide); - } - }); - connectionDetailHeaderContainer.setVisibility(VISIBLE); - } - - private int getFirstVisibleItemPosion() { - return ((LinearLayoutManager)connectionDetailLogs.getLayoutManager()).findFirstVisibleItemPosition(); - } - - protected void hideProgressBar() { - if (loadingScreen == null) { - return; - } - hideConnectionDetails(); - loadingScreen.setVisibility(GONE); - content.setVisibility(VISIBLE); - } - - protected void showProgressBar() { - if (loadingScreen == null) { - return; - } - content.setVisibility(GONE); - loadingScreen.setVisibility(VISIBLE); - } - - protected void setProgressbarTitle(@StringRes int progressbarTitle) { - if (loadingScreen == null) { - return; - } - this.progressbarTitle.setText(progressbarTitle); - } - - protected void setProgressbarDescription(String progressbarDescription) { - if (loadingScreen == null) { - return; - } - this.progressbarDescription.setText(progressbarDescription); - } - - protected void setConfigProgress(int value) { - if (loadingScreen == null) { - return; - } - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { - progressBar.setProgress(value); - } else { - progressBar.setProgress(value, true); - } - progressBar.setIndeterminate(value >= 100 || value < 0); - } - - - protected void showCompactLayout() { - if (isCompactLayout) { - return; - } - - if (isTabletLayoutInLandscape() || isPhoneLayout()) { - providerHeaderView.showCompactLayout(); - } - - showIncreasedTabletContentArea(); - isCompactLayout = true; - } - - protected void showStandardLayout() { - if (!isCompactLayout) { - return; - } - providerHeaderView.showStandardLayout(); - showStandardTabletContentArea(); - isCompactLayout = false; - } - - private boolean isTabletLayoutInLandscape() { - // TabletLayout is based on a ConstraintLayout and uses Guidelines whereas the phone layout - // has no such elements in it's layout xml file - return guideline_top != null && - guideline_bottom != null && - getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE; - } - - protected boolean isPhoneLayout() { - return guideline_top == null && guideline_bottom == null; - } - - protected boolean isTabletLayout() { - return guideline_top != null && guideline_bottom != null; - } - - /** - * Increases the white content area in tablet layouts - */ - private void showIncreasedTabletContentArea() { - if (isPhoneLayout()) { - return; - } - ConstraintLayout.LayoutParams guideLineTopParams = (ConstraintLayout.LayoutParams) guideline_top.getLayoutParams(); - float increasedTopPercentage = defaultGuidelineTopPercentage - GUIDE_LINE_COMPACT_DELTA; - guideLineTopParams.guidePercent = increasedTopPercentage > 0f ? increasedTopPercentage : 0f; - guideline_top.setLayoutParams(guideLineTopParams); - - ConstraintLayout.LayoutParams guideLineBottomParams = (ConstraintLayout.LayoutParams) guideline_bottom.getLayoutParams(); - float increasedBottomPercentage = defaultGuidelineBottomPercentage + GUIDE_LINE_COMPACT_DELTA; - guideLineBottomParams.guidePercent = increasedBottomPercentage < 1f ? increasedBottomPercentage : 1f; - guideline_bottom.setLayoutParams(guideLineBottomParams); - } - - /** - * Restores the default size of the white content area in tablet layouts - */ - private void showStandardTabletContentArea() { - if (isPhoneLayout()) { - return; - } - ConstraintLayout.LayoutParams guideLineTopParams = (ConstraintLayout.LayoutParams) guideline_top.getLayoutParams(); - guideLineTopParams.guidePercent = defaultGuidelineTopPercentage; - guideline_top.setLayoutParams(guideLineTopParams); - - ConstraintLayout.LayoutParams guideLineBottomParams = (ConstraintLayout.LayoutParams) guideline_bottom.getLayoutParams(); - guideLineBottomParams.guidePercent = defaultGuidelineBottomPercentage; - guideline_bottom.setLayoutParams(guideLineBottomParams); - } - - /** - * Checks if the keyboard is shown and switches between the standard layout and the compact layout - */ - private void setGlobalLayoutChangeListener() { - final View rootView = content.getRootView(); - rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - Rect r = new Rect(); - //r will be populated with the coordinates of your view that area still visible. - rootView.getWindowVisibleDisplayFrame(r); - - float deltaHiddenScreen = 1f - ((float) (r.bottom - r.top) / (float) rootView.getHeight()); - if (deltaHiddenScreen > 0.25f) { - // if more than 1/4 of the screen is hidden - showCompactLayout(); - } else { - showStandardLayout(); - } - } - }); - } - - @Override - public void update(Observable o, Object arg) { - if (o instanceof TorStatusObservable) { - runOnUiThread(() -> { - if (TorStatusObservable.getStatus() != TorStatusObservable.TorStatus.OFF && loadingScreen != null) { - if (connectionDetailContainer.getVisibility() == GONE) { - showConnectionDetails(); - } else { - setLogs(getLastTorLog(), getLastSnowflakeLog(), getLastLogs()); - } - } - setProgressbarDescription(getStringForCurrentStatus(ConfigWizardBaseActivity.this)); - setConfigProgress(getBootstrapProgress()); - }); - } - } - - protected void setLogs(String torLog, String snowflakeLog, List<String> lastLogs) { - if (loadingScreen == null) { - return; - } - torLogAdapter.updateData(lastLogs); - torState.setText(torLog); - snowflakeState.setText(snowflakeLog); - } - -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/CustomProviderSetupActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/CustomProviderSetupActivity.java deleted file mode 100644 index 520395f8..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/CustomProviderSetupActivity.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Copyright (c) 2018 LEAP Encryption Access Project and contributers - * - * 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, see <http://www.gnu.org/licenses/>. - */ -package se.leap.bitmaskclient.providersetup.activities; - -import android.content.Intent; -import android.content.res.AssetManager; -import android.os.Bundle; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.IOException; - -import se.leap.bitmaskclient.BuildConfig; -import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.base.models.Provider; -import se.leap.bitmaskclient.base.utils.ConfigHelper; -import se.leap.bitmaskclient.providersetup.ProviderAPICommand; - -import static se.leap.bitmaskclient.BuildConfig.customProviderApiIp; -import static se.leap.bitmaskclient.BuildConfig.customProviderIp; -import static se.leap.bitmaskclient.BuildConfig.customProviderMotdUrl; -import static se.leap.bitmaskclient.BuildConfig.customProviderUrl; -import static se.leap.bitmaskclient.BuildConfig.geoipUrl; -import static se.leap.bitmaskclient.base.models.Constants.EXT_JSON; -import static se.leap.bitmaskclient.base.models.Constants.EXT_PEM; -import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_CONFIGURE_LEAP; -import static se.leap.bitmaskclient.base.utils.ConfigHelper.preferAnonymousUsage; -import static se.leap.bitmaskclient.base.utils.InputStreamHelper.loadInputStreamAsString; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.SET_UP_PROVIDER; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.SETTING_UP_PROVIDER; - -/** - * Created by cyberta on 17.08.18. - */ - -public class CustomProviderSetupActivity extends ProviderSetupBaseActivity { - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setUpInitialUI(); - restoreState(savedInstanceState); - setDefaultProvider(); - } - - @Override - protected void onResume() { - super.onResume(); - if (getConfigState() == ProviderConfigState.PROVIDER_NOT_SET) { - showProgressBar(); - setupProvider(); - } - } - - private void setDefaultProvider() { - try { - AssetManager assetsManager = getAssets(); - Provider customProvider = new Provider(customProviderUrl, geoipUrl, customProviderMotdUrl, customProviderIp, customProviderApiIp); - String domain = ConfigHelper.getDomainFromMainURL(customProviderUrl); - String certificate = loadInputStreamAsString(assetsManager.open(domain + EXT_PEM)); - String providerDefinition = loadInputStreamAsString(assetsManager.open(domain + EXT_JSON)); - customProvider.setCaCert(certificate); - customProvider.define(new JSONObject(providerDefinition)); - setProvider(customProvider); - } catch (IOException | JSONException e) { - e.printStackTrace(); - setProvider(new Provider(customProviderUrl, geoipUrl, customProviderMotdUrl, customProviderIp, customProviderApiIp)); - } - } - - private void setUpInitialUI() { - setContentView(R.layout.a_custom_provider_setup); - setProviderHeaderText(R.string.setup_provider); - hideProgressBar(); - } - - private void setupProvider() { - setProviderConfigState(SETTING_UP_PROVIDER); - ProviderAPICommand.execute(this, SET_UP_PROVIDER, getProvider()); - } - - // ------- ProviderSetupInterface ---v - @Override - public void handleProviderSetUp(Provider provider) { - setProvider(provider); - if (provider.allowsAnonymous()) { - downloadVpnCertificate(); - } else { - showProviderDetails(); - } - } - - @Override - public void handleCorrectlyDownloadedCertificate(Provider provider) { - if (preferAnonymousUsage()) { - finishWithSetupWithProvider(provider); - } else { - this.provider = provider; - showProviderDetails(); - } - } - - // ------- DownloadFailedDialogInterface ---v - @Override - public void retrySetUpProvider(@NonNull Provider provider) { - setupProvider(); - showProgressBar(); - } - - @Override - public void cancelSettingUpProvider() { - super.cancelSettingUpProvider(); - finish(); - } - - @Override - public void addAndSelectNewProvider(String url) { - // ignore - } - - private void finishWithSetupWithProvider(Provider provider) { - Intent intent = new Intent(); - intent.putExtra(Provider.KEY, provider); - setResult(RESULT_OK, intent); - finish(); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == REQUEST_CODE_CONFIGURE_LEAP) { - setResult(resultCode, data); - finish(); - } - } -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/LoginActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/LoginActivity.java deleted file mode 100644 index 9a5f31f2..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/LoginActivity.java +++ /dev/null @@ -1,32 +0,0 @@ -package se.leap.bitmaskclient.providersetup.activities; - -import android.os.Bundle; -import androidx.annotation.Nullable; - -import butterknife.OnClick; -import se.leap.bitmaskclient.R; - -/** - * Activity to login to chosen Provider - * - * Created by fupduck on 09.01.18. - */ - -public class LoginActivity extends ProviderCredentialsBaseActivity { - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setProgressbarTitle(R.string.logging_in); - setProviderHeaderLogo(R.drawable.logo); - setProviderHeaderText(R.string.login_to_profile); - } - - @Override - @OnClick(R.id.button) - void handleButton() { - super.handleButton(); - login(getUsername(), getPassword()); - } - -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ProviderCredentialsBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ProviderCredentialsBaseActivity.java deleted file mode 100644 index e186ce5d..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ProviderCredentialsBaseActivity.java +++ /dev/null @@ -1,479 +0,0 @@ -/** - * Copyright (c) 2018 LEAP Encryption Access Project and contributers - * - * 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, see <http://www.gnu.org/licenses/>. - */ -package se.leap.bitmaskclient.providersetup.activities; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Build; -import android.os.Build.VERSION_CODES; -import android.os.Bundle; -import androidx.annotation.Nullable; -import androidx.annotation.StringRes; -import com.google.android.material.textfield.TextInputEditText; -import com.google.android.material.textfield.TextInputLayout; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; -import androidx.appcompat.widget.AppCompatButton; -import androidx.appcompat.widget.AppCompatTextView; -import android.text.Editable; -import android.text.Html; -import android.text.TextWatcher; -import android.text.method.LinkMovementMethod; -import android.text.util.Linkify; -import android.util.Log; -import android.view.KeyEvent; -import android.view.inputmethod.InputMethodManager; -import android.widget.TextView; - -import org.json.JSONArray; -import org.json.JSONException; - -import butterknife.BindView; -import butterknife.OnClick; -import se.leap.bitmaskclient.base.models.Constants.CREDENTIAL_ERRORS; -import se.leap.bitmaskclient.base.models.Provider; -import se.leap.bitmaskclient.providersetup.ProviderAPI; -import se.leap.bitmaskclient.providersetup.ProviderAPICommand; -import se.leap.bitmaskclient.R; - -import static android.text.TextUtils.isEmpty; -import static android.view.View.GONE; -import static android.view.View.VISIBLE; -import static android.view.inputmethod.EditorInfo.IME_ACTION_DONE; -import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_PROVIDER_API_EVENT; -import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_CODE; -import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_RESULT_KEY; -import static se.leap.bitmaskclient.base.models.Constants.CREDENTIALS_PASSWORD; -import static se.leap.bitmaskclient.base.models.Constants.CREDENTIALS_USERNAME; -import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.DOWNLOAD_VPN_CERTIFICATE; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.LOG_IN; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.SIGN_UP; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.USER_MESSAGE; - -/** - * Base Activity for activities concerning a provider interaction - * - * Created by fupduck on 09.01.18. - */ - -public abstract class ProviderCredentialsBaseActivity extends ConfigWizardBaseActivity { - - final protected static String TAG = ProviderCredentialsBaseActivity.class.getName(); - - final private static String ACTIVITY_STATE = "ACTIVITY STATE"; - - final private static String SHOWING_FORM = "SHOWING_FORM"; - final private static String PERFORMING_ACTION = "PERFORMING_ACTION"; - final private static String USERNAME_ERROR = "USERNAME_ERROR"; - final private static String PASSWORD_ERROR = "PASSWORD_ERROR"; - final private static String PASSWORD_VERIFICATION_ERROR = "PASSWORD_VERIFICATION_ERROR"; - - protected Intent mConfigState = new Intent(SHOWING_FORM); - protected ProviderAPIBroadcastReceiver providerAPIBroadcastReceiver; - - @BindView(R.id.provider_credentials_user_message) - AppCompatTextView userMessage; - - @BindView(R.id.provider_credentials_username) - TextInputEditText usernameField; - - @BindView(R.id.provider_credentials_password) - TextInputEditText passwordField; - - @BindView(R.id.provider_credentials_password_verification) - TextInputEditText passwordVerificationField; - - @BindView(R.id.provider_credentials_username_error) - TextInputLayout usernameError; - - @BindView(R.id.provider_credentials_password_error) - TextInputLayout passwordError; - - @BindView(R.id.provider_credentials_password_verification_error) - TextInputLayout passwordVerificationError; - - @BindView(R.id.button) - AppCompatButton button; - - private boolean isUsernameError = false; - private boolean isPasswordError = false; - private boolean isVerificationError = false; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.a_provider_credentials); - providerAPIBroadcastReceiver = new ProviderAPIBroadcastReceiver(); - - IntentFilter updateIntentFilter = new IntentFilter(BROADCAST_PROVIDER_API_EVENT); - updateIntentFilter.addCategory(Intent.CATEGORY_DEFAULT); - LocalBroadcastManager.getInstance(this).registerReceiver(providerAPIBroadcastReceiver, updateIntentFilter); - - setUpListeners(); - restoreState(savedInstanceState); - - String userMessageString = getIntent().getStringExtra(USER_MESSAGE); - if (userMessageString != null) { - userMessage.setText(userMessageString); - userMessage.setVisibility(VISIBLE); - } - } - - @Override - protected void onResume() { - super.onResume(); - - String action = mConfigState.getAction(); - if (action == null) { - return; - } - - if(action.equalsIgnoreCase(PERFORMING_ACTION)) { - showProgressBar(); - } - } - - protected void restoreState(Bundle savedInstance) { - super.restoreState(savedInstance); - if (savedInstance == null) { - return; - } - if (savedInstance.getString(USER_MESSAGE) != null) { - userMessage.setText(savedInstance.getString(USER_MESSAGE)); - userMessage.setVisibility(VISIBLE); - } - updateUsernameError(savedInstance.getString(USERNAME_ERROR)); - updatePasswordError(savedInstance.getString(PASSWORD_ERROR)); - updateVerificationError(savedInstance.getString(PASSWORD_VERIFICATION_ERROR)); - if (savedInstance.getString(ACTIVITY_STATE) != null) { - mConfigState.setAction(savedInstance.getString(ACTIVITY_STATE)); - } - } - - private void updateUsernameError(String usernameErrorString) { - usernameError.setError(usernameErrorString); - isUsernameError = usernameErrorString != null; - updateButton(); - } - - private void updatePasswordError(String passwordErrorString) { - passwordError.setError(passwordErrorString); - isPasswordError = passwordErrorString != null; - updateButton(); - } - - private void updateVerificationError(String verificationErrorString) { - passwordVerificationError.setError(verificationErrorString); - isVerificationError = verificationErrorString != null; - updateButton(); - } - - private void updateButton() { - button.setEnabled(!isPasswordError && - !isUsernameError && - !isVerificationError && - !isEmpty(passwordField.getText()) && - !isEmpty(usernameField.getText()) && - !(passwordVerificationField.getVisibility() == VISIBLE && - getPasswordVerification().length() == 0)); - } - - @Override - public void onSaveInstanceState(Bundle outState) { - outState.putString(ACTIVITY_STATE, mConfigState.getAction()); - if (userMessage.getText() != null && userMessage.getVisibility() == VISIBLE) { - outState.putString(USER_MESSAGE, userMessage.getText().toString()); - } - if (usernameError.getError() != null) { - outState.putString(USERNAME_ERROR, usernameError.getError().toString()); - } - if (passwordError.getError() != null) { - outState.putString(PASSWORD_ERROR, passwordError.getError().toString()); - } - if (passwordVerificationError.getError() != null) { - outState.putString(PASSWORD_VERIFICATION_ERROR, passwordVerificationError.getError().toString()); - } - - super.onSaveInstanceState(outState); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (providerAPIBroadcastReceiver != null) - LocalBroadcastManager.getInstance(this).unregisterReceiver(providerAPIBroadcastReceiver); - } - - @OnClick(R.id.button) - void handleButton() { - mConfigState.setAction(PERFORMING_ACTION); - hideKeyboard(); - showProgressBar(); - } - - protected void setButtonText(@StringRes int buttonText) { - button.setText(buttonText); - } - - String getUsername() { - String username = usernameField.getText().toString(); - String providerDomain = provider.getDomain(); - if (username.endsWith(providerDomain)) { - try { - return username.split("@" + providerDomain)[0]; - } catch (ArrayIndexOutOfBoundsException e) { - return ""; - } - } - return username; - } - - String getPassword() { - return passwordField.getText().toString(); - } - - String getPasswordVerification() { - return passwordVerificationField.getText().toString(); - } - - void login(String username, String password) { - - Bundle parameters = bundleUsernameAndPassword(username, password); - ProviderAPICommand.execute(this, LOG_IN, parameters, provider); - } - - public void signUp(String username, String password) { - - Bundle parameters = bundleUsernameAndPassword(username, password); - ProviderAPICommand.execute(this, SIGN_UP, parameters, provider); - } - - void downloadVpnCertificate(Provider handledProvider) { - provider = handledProvider; - ProviderAPICommand.execute(this, DOWNLOAD_VPN_CERTIFICATE, provider); - } - - protected Bundle bundleUsernameAndPassword(String username, String password) { - Bundle parameters = new Bundle(); - if (!username.isEmpty()) - parameters.putString(CREDENTIALS_USERNAME, username); - if (!password.isEmpty()) - parameters.putString(CREDENTIALS_PASSWORD, password); - return parameters; - } - - private void setUpListeners() { - usernameField.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public void afterTextChanged(Editable s) { - if (getUsername().equalsIgnoreCase("")) { - s.clear(); - updateUsernameError(getString(R.string.username_ask)); - } else { - updateUsernameError(null); - String suffix = "@" + provider.getDomain(); - if (!usernameField.getText().toString().endsWith(suffix)) { - s.append(suffix); - usernameField.setSelection(usernameField.getText().toString().indexOf('@')); - } - } - } - }); - usernameField.setOnEditorActionListener(new TextView.OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (actionId == IME_ACTION_DONE - || event != null && event.getAction() == KeyEvent.ACTION_DOWN - && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { - passwordField.requestFocus(); - return true; - } - return false; - } - }); - - passwordField.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public void afterTextChanged(Editable s) { - if(getPassword().length() < 8) { - updatePasswordError(getString(R.string.error_not_valid_password_user_message)); - } else { - updatePasswordError(null); - } - } - }); - passwordField.setOnEditorActionListener(new TextView.OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (actionId == IME_ACTION_DONE - || event != null && event.getAction() == KeyEvent.ACTION_DOWN - && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { - if (passwordVerificationField.getVisibility() == VISIBLE) { - passwordVerificationField.requestFocus(); - } else { - button.performClick(); - } - return true; - } - return false; - } - }); - - passwordVerificationField.addTextChangedListener(new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public void afterTextChanged(Editable s) { - if(getPassword().equals(getPasswordVerification())) { - updateVerificationError(null); - } else { - updateVerificationError(getString(R.string.password_mismatch)); - } - } - }); - passwordVerificationField.setOnEditorActionListener(new TextView.OnEditorActionListener() { - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (actionId == IME_ACTION_DONE - || event != null && event.getAction() == KeyEvent.ACTION_DOWN - && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { - button.performClick(); - return true; - } - return false; - } - }); - } - - private void hideKeyboard() { - InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); - if (imm != null) { - imm.hideSoftInputFromWindow(passwordField.getWindowToken(), 0); - } - } - - private void handleReceivedErrors(Bundle arguments) { - if (arguments.containsKey(CREDENTIAL_ERRORS.PASSWORD_INVALID_LENGTH.toString())) { - updatePasswordError(getString(R.string.error_not_valid_password_user_message)); - } else if (arguments.containsKey(CREDENTIAL_ERRORS.RISEUP_WARNING.toString())) { - userMessage.setVisibility(VISIBLE); - userMessage.setText(R.string.login_riseup_warning); - } - if (arguments.containsKey(CREDENTIALS_USERNAME)) { - String username = arguments.getString(CREDENTIALS_USERNAME); - usernameField.setText(username); - } - if (arguments.containsKey(CREDENTIAL_ERRORS.USERNAME_MISSING.toString())) { - updateUsernameError(getString(R.string.username_ask)); - } - if (arguments.containsKey(USER_MESSAGE)) { - String userMessageString = arguments.getString(USER_MESSAGE); - try { - userMessageString = new JSONArray(userMessageString).getString(0); - } catch (JSONException e) { - e.printStackTrace(); - } - - if (Build.VERSION.SDK_INT >= VERSION_CODES.N) { - userMessage.setText(Html.fromHtml(userMessageString, Html.FROM_HTML_MODE_LEGACY)); - } else { - userMessage.setText(Html.fromHtml(userMessageString)); - } - Linkify.addLinks(userMessage, Linkify.ALL); - userMessage.setMovementMethod(LinkMovementMethod.getInstance()); - userMessage.setVisibility(VISIBLE); - } else if (userMessage.getVisibility() != GONE) { - userMessage.setVisibility(GONE); - } - - if (!usernameField.getText().toString().isEmpty() && passwordField.isFocusable()) - passwordField.requestFocus(); - - mConfigState.setAction(SHOWING_FORM); - hideProgressBar(); - } - - private void successfullyFinished(Provider handledProvider) { - provider = handledProvider; - Intent resultData = new Intent(); - resultData.putExtra(Provider.KEY, provider); - setResult(RESULT_OK, resultData); - finish(); - } - - //TODO: replace with EipSetupObserver - public class ProviderAPIBroadcastReceiver extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - Log.d(TAG, "received Broadcast"); - - String action = intent.getAction(); - if (action == null || !action.equalsIgnoreCase(BROADCAST_PROVIDER_API_EVENT)) { - return; - } - - int resultCode = intent.getIntExtra(BROADCAST_RESULT_CODE, RESULT_CANCELED); - Bundle resultData = intent.getParcelableExtra(BROADCAST_RESULT_KEY); - Provider handledProvider = resultData.getParcelable(PROVIDER_KEY); - - switch (resultCode) { - case ProviderAPI.SUCCESSFUL_SIGNUP: - String password = resultData.getString(CREDENTIALS_PASSWORD); - String username = resultData.getString(CREDENTIALS_USERNAME); - login(username, password); - break; - case ProviderAPI.SUCCESSFUL_LOGIN: - downloadVpnCertificate(handledProvider); - break; - case ProviderAPI.FAILED_LOGIN: - case ProviderAPI.FAILED_SIGNUP: - handleReceivedErrors((Bundle) intent.getParcelableExtra(BROADCAST_RESULT_KEY)); - break; - - case ProviderAPI.INCORRECTLY_DOWNLOADED_VPN_CERTIFICATE: - // error handling takes place in MainActivity - case ProviderAPI.CORRECTLY_DOWNLOADED_VPN_CERTIFICATE: - successfullyFinished(handledProvider); - break; - } - } - } -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ProviderListBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ProviderListBaseActivity.java deleted file mode 100644 index eb9898b8..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ProviderListBaseActivity.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Copyright (c) 2017 LEAP Encryption Access Project and contributors - * <p> - * 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. - * <p> - * 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. - * <p> - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package se.leap.bitmaskclient.providersetup.activities; - -import android.content.Intent; -import android.os.Bundle; -import android.widget.ListView; - -import androidx.annotation.NonNull; - -import com.pedrogomez.renderers.Renderer; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; - -import butterknife.BindView; -import butterknife.OnItemClick; -import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.base.models.Provider; -import se.leap.bitmaskclient.providersetup.AddProviderActivity; -import se.leap.bitmaskclient.providersetup.ProviderListActivity; -import se.leap.bitmaskclient.providersetup.ProviderListAdapter; -import se.leap.bitmaskclient.providersetup.ProviderRenderer; -import se.leap.bitmaskclient.providersetup.ProviderRendererBuilder; - -import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_ADD_PROVIDER; -import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_CONFIGURE_LEAP; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.SETTING_UP_PROVIDER; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.SHOW_FAILED_DIALOG; - -/** - * abstract base Activity that builds and shows the list of known available providers. - * The implementation of ProviderListBaseActivity differ in that they may or may not allow to bypass - * secure download mechanisms including certificate validation. - * <p/> - * It also allows the user to enter custom providers with a button. - * - * @author parmegv - * @author cyberta - */ - -public abstract class ProviderListBaseActivity extends ProviderSetupBaseActivity { - - @BindView(R.id.provider_list) - protected ListView providerListView; - @Inject - protected ProviderListAdapter adapter; - - final public static String TAG = ProviderListActivity.class.getSimpleName(); - final protected static String EXTRAS_KEY_INVALID_URL = "INVALID_URL"; - - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setUpInitialUI(); - initProviderList(); - restoreState(savedInstanceState); - } - - public abstract void retrySetUpProvider(@NonNull Provider provider); - - protected abstract void onItemSelectedLogic(); - - private void initProviderList() { - List<Renderer<Provider>> prototypes = new ArrayList<>(); - prototypes.add(new ProviderRenderer(this)); - ProviderRendererBuilder providerRendererBuilder = new ProviderRendererBuilder(prototypes); - adapter = new ProviderListAdapter(getLayoutInflater(), providerRendererBuilder, getProviderManager()); - providerListView.setAdapter(adapter); - } - - private void setUpInitialUI() { - setContentView(R.layout.a_provider_list); - setProviderHeaderText(R.string.setup_provider); - hideProgressBar(); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == REQUEST_CODE_CONFIGURE_LEAP) { - if (resultCode == RESULT_OK) { - setResult(resultCode, data); - finish(); - } - } else if (requestCode == REQUEST_CODE_ADD_PROVIDER) { - if (resultCode == RESULT_OK) { - testNewURL = true; - String newUrl = data.getStringExtra(AddProviderActivity.EXTRAS_KEY_NEW_URL); - this.provider.setMainUrl(newUrl); - showAndSelectProvider(newUrl); - } else { - cancelSettingUpProvider(); - } - } - } - - public void showAndSelectProvider(String newURL) { - provider = new Provider(newURL); - autoSelectProvider(); - } - - private void autoSelectProvider() { - onItemSelectedLogic(); - showProgressBar(); - } - - // ------- ProviderSetupInterface ---v - @Override - public void handleProviderSetUp(Provider handledProvider) { - this.provider = handledProvider; - adapter.add(provider); - adapter.saveProviders(); - if (provider.allowsAnonymous()) { - //FIXME: providerApiBroadcastReceiver.getConfigState().putExtra(SERVICES_RETRIEVED, true); DEAD CODE??? - downloadVpnCertificate(); - } else { - showProviderDetails(); - } - } - - @Override - public void handleCorrectlyDownloadedCertificate(Provider handledProvider) { - this.provider = handledProvider; - showProviderDetails(); - } - - @OnItemClick(R.id.provider_list) - void onItemSelected(int position) { - if (SETTING_UP_PROVIDER == getConfigState() || - SHOW_FAILED_DIALOG == getConfigState()) { - return; - } - - //TODO Code 2 pane view - provider = adapter.getItem(position); - if (provider != null && !provider.isDefault()) { - //TODO Code 2 pane view - providerConfigState = SETTING_UP_PROVIDER; - showProgressBar(); - onItemSelectedLogic(); - } else { - addAndSelectNewProvider(); - } - } - - @Override - public void onBackPressed() { - if (SETTING_UP_PROVIDER == providerConfigState || - SHOW_FAILED_DIALOG == providerConfigState) { - cancelSettingUpProvider(); - } else { - super.onBackPressed(); - } - } - - /** - * Open the new provider dialog - */ - public void addAndSelectNewProvider() { - Intent intent = new Intent(this, AddProviderActivity.class); - startActivityForResult(intent, REQUEST_CODE_ADD_PROVIDER); - } - - /** - * Open the new provider dialog - */ - @Override - public void addAndSelectNewProvider(String url) { - testNewURL = false; - Intent intent = new Intent(this, AddProviderActivity.class); - intent.putExtra(EXTRAS_KEY_INVALID_URL, url); - startActivityForResult(intent, REQUEST_CODE_ADD_PROVIDER); - } - -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ProviderSetupBaseActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ProviderSetupBaseActivity.java deleted file mode 100644 index e429f776..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/ProviderSetupBaseActivity.java +++ /dev/null @@ -1,256 +0,0 @@ -/** - * Copyright (c) 2018 LEAP Encryption Access Project and contributers - * - * 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, see <http://www.gnu.org/licenses/>. - */ -package se.leap.bitmaskclient.providersetup.activities; - -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.util.Log; -import android.view.View; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.fragment.app.DialogFragment; -import androidx.fragment.app.FragmentTransaction; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; - -import org.json.JSONException; -import org.json.JSONObject; -import org.torproject.jni.TorService; - -import se.leap.bitmaskclient.base.FragmentManagerEnhanced; -import se.leap.bitmaskclient.base.models.Provider; -import se.leap.bitmaskclient.providersetup.ProviderAPICommand; -import se.leap.bitmaskclient.providersetup.ProviderApiSetupBroadcastReceiver; -import se.leap.bitmaskclient.providersetup.ProviderDetailActivity; -import se.leap.bitmaskclient.providersetup.ProviderManager; -import se.leap.bitmaskclient.providersetup.ProviderSetupFailedDialog; -import se.leap.bitmaskclient.providersetup.ProviderSetupInterface; -import se.leap.bitmaskclient.tor.TorServiceCommand; -import se.leap.bitmaskclient.tor.TorStatusObservable; - -import static se.leap.bitmaskclient.base.models.Constants.BROADCAST_PROVIDER_API_EVENT; -import static se.leap.bitmaskclient.base.models.Constants.PROVIDER_KEY; -import static se.leap.bitmaskclient.base.models.Constants.REQUEST_CODE_CONFIGURE_LEAP; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.DOWNLOAD_VPN_CERTIFICATE; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.ERRORS; -import static se.leap.bitmaskclient.providersetup.ProviderAPI.UPDATE_PROVIDER_DETAILS; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.PENDING_SHOW_FAILED_DIALOG; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.PENDING_SHOW_PROVIDER_DETAILS; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.PROVIDER_NOT_SET; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.SETTING_UP_PROVIDER; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.SHOWING_PROVIDER_DETAILS; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.SHOW_FAILED_DIALOG; -import static se.leap.bitmaskclient.tor.TorStatusObservable.TorStatus.OFF; - -/** - * Created by cyberta on 19.08.18. - */ - -public abstract class ProviderSetupBaseActivity extends ConfigWizardBaseActivity implements ProviderSetupInterface, ProviderSetupFailedDialog.DownloadFailedDialogInterface { - final public static String TAG = "ProviderSetupActivity"; - final private static String ACTIVITY_STATE = "ACTIVITY STATE"; - final private static String REASON_TO_FAIL = "REASON TO FAIL"; - - protected ProviderSetupInterface.ProviderConfigState providerConfigState = PROVIDER_NOT_SET; - private ProviderManager providerManager; - private FragmentManagerEnhanced fragmentManager; - - private String reasonToFail; - protected boolean testNewURL; - - private ProviderApiSetupBroadcastReceiver providerAPIBroadcastReceiver; - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - fragmentManager = new FragmentManagerEnhanced(getSupportFragmentManager()); - providerManager = ProviderManager.getInstance(getAssets(), getExternalFilesDir(null)); - setUpProviderAPIResultReceiver(); - } - - @Override - protected void onResume() { - super.onResume(); - Log.d(TAG, "resuming with ConfigState: " + providerConfigState.toString()); - if (SETTING_UP_PROVIDER == providerConfigState) { - showProgressBar(); - } else if (PENDING_SHOW_FAILED_DIALOG == providerConfigState) { - showProgressBar(); - hideConnectionDetails(); - showDownloadFailedDialog(); - } else if (SHOW_FAILED_DIALOG == providerConfigState) { - showProgressBar(); - hideConnectionDetails(); - } else if (SHOWING_PROVIDER_DETAILS == providerConfigState) { - cancelSettingUpProvider(false); - } else if (PENDING_SHOW_PROVIDER_DETAILS == providerConfigState) { - showProviderDetails(); - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (providerAPIBroadcastReceiver != null) { - LocalBroadcastManager.getInstance(this).unregisterReceiver(providerAPIBroadcastReceiver); - } - providerAPIBroadcastReceiver = null; - } - - - @Override - public void onSaveInstanceState(@NonNull Bundle outState) { - outState.putString(ACTIVITY_STATE, providerConfigState.toString()); - outState.putString(REASON_TO_FAIL, reasonToFail); - - super.onSaveInstanceState(outState); - } - - protected FragmentManagerEnhanced getFragmentManagerEnhanced() { - return fragmentManager; - } - - protected ProviderManager getProviderManager() { - return providerManager; - } - - protected void setProviderConfigState(ProviderConfigState state) { - this.providerConfigState = state; - } - - protected void setProvider(Provider provider) { - this.provider = provider; - } - - // --------- ProviderSetupInterface ---v - @Override - public Provider getProvider() { - return provider; - } - - @Override - public ProviderConfigState getConfigState() { - return providerConfigState; - } - - @Override - public void handleError(Bundle resultData) { - reasonToFail = resultData.getString(ERRORS); - showDownloadFailedDialog(); - } - - @Override - public void handleIncorrectlyDownloadedCertificate() { - cancelSettingUpProvider(); - setResult(RESULT_CANCELED, new Intent(getConfigState().toString())); - } - - // -------- DownloadFailedDialogInterface ---v - @Override - public void cancelSettingUpProvider() { - cancelSettingUpProvider(true); - } - - @Override - public void updateProviderDetails() { - providerConfigState = SETTING_UP_PROVIDER; - ProviderAPICommand.execute(this, UPDATE_PROVIDER_DETAILS, provider); - } - - public void cancelSettingUpProvider(boolean stopTor) { - if (stopTor && TorStatusObservable.getStatus() != OFF) { - Log.d(TAG, "SHUTDOWN - cancelSettingUpProvider stopTor:" + stopTor); - TorServiceCommand.stopTorServiceAsync(this); - } - providerConfigState = PROVIDER_NOT_SET; - provider = null; - hideProgressBar(); - } - - protected void restoreState(Bundle savedInstanceState) { - super.restoreState(savedInstanceState); - if (savedInstanceState == null) { - return; - } - this.providerConfigState = ProviderSetupInterface.ProviderConfigState.valueOf(savedInstanceState.getString(ACTIVITY_STATE, PROVIDER_NOT_SET.toString())); - if (savedInstanceState.containsKey(REASON_TO_FAIL)) { - reasonToFail = savedInstanceState.getString(REASON_TO_FAIL); - } - } - - private void setUpProviderAPIResultReceiver() { - providerAPIBroadcastReceiver = new ProviderApiSetupBroadcastReceiver(this); - - IntentFilter updateIntentFilter = new IntentFilter(BROADCAST_PROVIDER_API_EVENT); - updateIntentFilter.addCategory(Intent.CATEGORY_DEFAULT); - LocalBroadcastManager.getInstance(this).registerReceiver(providerAPIBroadcastReceiver, updateIntentFilter); - } - - /** - * Asks ProviderApiService to download an anonymous (anon) VPN certificate. - */ - protected void downloadVpnCertificate() { - ProviderAPICommand.execute(this, DOWNLOAD_VPN_CERTIFICATE, provider); - } - - /** - * Once selected a provider, this fragment offers the user to log in, - * use it anonymously (if possible) - * or cancel their selection pressing the back button. - */ - public void showProviderDetails() { - // show only if current activity is shown - if (isActivityShowing && - providerConfigState != SHOWING_PROVIDER_DETAILS) { - providerConfigState = SHOWING_PROVIDER_DETAILS; - Intent intent = new Intent(this, ProviderDetailActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); - intent.putExtra(PROVIDER_KEY, provider); - startActivityForResult(intent, REQUEST_CODE_CONFIGURE_LEAP); - } else { - providerConfigState = PENDING_SHOW_PROVIDER_DETAILS; - } - } - - /** - * Shows an error dialog, if configuring of a provider failed. - */ - public void showDownloadFailedDialog() { - try { - providerConfigState = SHOW_FAILED_DIALOG; - hideConnectionDetails(); - FragmentTransaction fragmentTransaction = fragmentManager.removePreviousFragment(ProviderSetupFailedDialog.TAG); - DialogFragment newFragment; - try { - JSONObject errorJson = new JSONObject(reasonToFail); - newFragment = ProviderSetupFailedDialog.newInstance(provider, errorJson, testNewURL); - } catch (JSONException e) { - e.printStackTrace(); - newFragment = ProviderSetupFailedDialog.newInstance(provider, reasonToFail); - } catch (NullPointerException e) { - //reasonToFail was null - return; - } - newFragment.show(fragmentTransaction, ProviderSetupFailedDialog.TAG); - } catch (IllegalStateException e) { - e.printStackTrace(); - providerConfigState = PENDING_SHOW_FAILED_DIALOG; - } - } - -} diff --git a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SignupActivity.java b/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SignupActivity.java deleted file mode 100644 index 16007a70..00000000 --- a/app/src/main/java/se/leap/bitmaskclient/providersetup/activities/SignupActivity.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2018 LEAP Encryption Access Project and contributers - * - * 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, see <http://www.gnu.org/licenses/>. - */ -package se.leap.bitmaskclient.providersetup.activities; - -import android.os.Bundle; -import androidx.annotation.Nullable; - -import butterknife.OnClick; -import se.leap.bitmaskclient.R; - -import static android.view.View.VISIBLE; - -/** - * Create an account with a provider - */ - -public class SignupActivity extends ProviderCredentialsBaseActivity { - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setProviderHeaderLogo(R.drawable.logo); - setProviderHeaderText(R.string.create_profile); - - setProgressbarTitle(R.string.signing_up); - setButtonText(R.string.signup_button); - - passwordVerificationField.setVisibility(VISIBLE); - passwordVerificationError.setVisibility(VISIBLE); - } - - @Override - @OnClick(R.id.button) - void handleButton() { - super.handleButton(); - if (getPassword().equals(getPasswordVerification())) { - signUp(getUsername(), getPassword()); - } - } -} diff --git a/app/src/main/res/layout-xlarge-port/a_add_provider.xml b/app/src/main/res/layout-xlarge-port/a_add_provider.xml deleted file mode 100644 index 80eef3c3..00000000 --- a/app/src/main/res/layout-xlarge-port/a_add_provider.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - style="@style/BitmaskActivity" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.activities.ProviderCredentialsBaseActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.275" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.725" /> - - <include layout="@layout/a_add_provider_tablet_scrollview"/> -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout-xlarge-port/a_custom_provider_setup.xml b/app/src/main/res/layout-xlarge-port/a_custom_provider_setup.xml deleted file mode 100644 index dfb58b8c..00000000 --- a/app/src/main/res/layout-xlarge-port/a_custom_provider_setup.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/provider_list_layout" - style="@style/BitmaskActivity" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.activities.CustomProviderSetupActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.275" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.725" /> - - <include layout="@layout/a_custom_provider_setup_tablet_linear_layout" /> - -</androidx.constraintlayout.widget.ConstraintLayout> diff --git a/app/src/main/res/layout-xlarge-port/a_provider_credentials.xml b/app/src/main/res/layout-xlarge-port/a_provider_credentials.xml deleted file mode 100644 index e1295853..00000000 --- a/app/src/main/res/layout-xlarge-port/a_provider_credentials.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - style="@style/BitmaskActivity" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.activities.ProviderCredentialsBaseActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.275" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.725" /> - - <include layout="@layout/a_provider_credentials_tablet_linear_layout"/> -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout-xlarge-port/a_provider_detail.xml b/app/src/main/res/layout-xlarge-port/a_provider_detail.xml deleted file mode 100644 index 34719df9..00000000 --- a/app/src/main/res/layout-xlarge-port/a_provider_detail.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/provider_list_layout" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.ProviderDetailActivity" - style="@style/BitmaskActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.275" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.725" /> - - <include layout="@layout/a_provider_detail_tablet_linear_layout" /> -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout-xlarge-port/a_provider_list.xml b/app/src/main/res/layout-xlarge-port/a_provider_list.xml deleted file mode 100644 index 184cbf93..00000000 --- a/app/src/main/res/layout-xlarge-port/a_provider_list.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/provider_list_layout" - style="@style/BitmaskActivity" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.ProviderListActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.275" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.725" /> - - <include layout="@layout/a_provider_list_tablet_linear_layout" /> -</androidx.constraintlayout.widget.ConstraintLayout> diff --git a/app/src/main/res/layout-xlarge/a_add_provider.xml b/app/src/main/res/layout-xlarge/a_add_provider.xml deleted file mode 100644 index db63b32c..00000000 --- a/app/src/main/res/layout-xlarge/a_add_provider.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - style="@style/BitmaskActivity" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.activities.ProviderCredentialsBaseActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.15" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.85" /> - - <include layout="@layout/a_add_provider_tablet_scrollview"/> -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/a_custom_provider_setup.xml b/app/src/main/res/layout-xlarge/a_custom_provider_setup.xml deleted file mode 100644 index 130ad95a..00000000 --- a/app/src/main/res/layout-xlarge/a_custom_provider_setup.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/provider_list_layout" - style="@style/BitmaskActivity" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.activities.CustomProviderSetupActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.15" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.85" /> - - <include layout="@layout/a_custom_provider_setup_tablet_linear_layout" /> - -</androidx.constraintlayout.widget.ConstraintLayout> diff --git a/app/src/main/res/layout-xlarge/a_provider_credentials.xml b/app/src/main/res/layout-xlarge/a_provider_credentials.xml deleted file mode 100644 index 61a638d4..00000000 --- a/app/src/main/res/layout-xlarge/a_provider_credentials.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - style="@style/BitmaskActivity" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.activities.ProviderCredentialsBaseActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.15" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.85" /> - - <include layout="@layout/a_provider_credentials_tablet_linear_layout"/> -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/a_provider_detail.xml b/app/src/main/res/layout-xlarge/a_provider_detail.xml deleted file mode 100644 index 74a0c72c..00000000 --- a/app/src/main/res/layout-xlarge/a_provider_detail.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/provider_list_layout" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.ProviderDetailActivity" - style="@style/BitmaskActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.15" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.85" /> - - <include layout="@layout/a_provider_detail_tablet_linear_layout" /> -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout-xlarge/a_provider_list.xml b/app/src/main/res/layout-xlarge/a_provider_list.xml deleted file mode 100644 index c8c7a763..00000000 --- a/app/src/main/res/layout-xlarge/a_provider_list.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/provider_list_layout" - style="@style/BitmaskActivity" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.ProviderListActivity" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="match_parent" - android:layout_height="match_parent" - app:srcCompat="@drawable/background_main" - android:scaleType="centerCrop" - /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_left" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.2" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_right" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_percent="0.8" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_top" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.15" /> - - <androidx.constraintlayout.widget.Guideline - android:id="@+id/guideline_bottom" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="horizontal" - app:layout_constraintGuide_percent="0.85" /> - - <include layout="@layout/a_provider_list_tablet_linear_layout" /> -</androidx.constraintlayout.widget.ConstraintLayout> diff --git a/app/src/main/res/layout-xlarge/f_about.xml b/app/src/main/res/layout-xlarge/f_about.xml index ed7f4f1a..90a263a0 100644 --- a/app/src/main/res/layout-xlarge/f_about.xml +++ b/app/src/main/res/layout-xlarge/f_about.xml @@ -1,3 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> + <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/aboutLayout" @@ -8,8 +10,7 @@ android:layout_marginStart="@dimen/stdpadding" android:layout_marginEnd="@dimen/stdpadding" android:layout_marginRight="@dimen/stdpadding" - tools:context=".base.MainActivity" - tools:viewBindingIgnore="true"> + tools:context=".base.MainActivity"> <LinearLayout android:layout_width="match_parent" diff --git a/app/src/main/res/layout-xlarge/v_provider_list_item.xml b/app/src/main/res/layout-xlarge/v_provider_list_item.xml deleted file mode 100644 index 2e3506b5..00000000 --- a/app/src/main/res/layout-xlarge/v_provider_list_item.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:paddingTop="2dip" - android:paddingBottom="2dip" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="?android:attr/activatedBackgroundIndicator" - android:minHeight="?android:attr/listPreferredItemHeight" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatTextView android:id="@+id/provider_domain" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingStart="?android:attr/listPreferredItemPaddingStart" - android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" - android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" - android:paddingRight="?android:attr/listPreferredItemPaddingRight" - android:layout_marginTop="6dip" - android:textAppearance="?android:attr/textAppearanceLarge" - /> - - <androidx.appcompat.widget.AppCompatTextView android:id="@+id/provider_name" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingStart="?android:attr/listPreferredItemPaddingStart" - android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" - android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" - android:paddingRight="?android:attr/listPreferredItemPaddingRight" - android:textAppearance="?android:attr/textAppearanceMedium" - /> - -</LinearLayout> diff --git a/app/src/main/res/layout/a_add_provider.xml b/app/src/main/res/layout/a_add_provider.xml deleted file mode 100644 index aad64630..00000000 --- a/app/src/main/res/layout/a_add_provider.xml +++ /dev/null @@ -1,90 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - style="@style/BitmaskActivity" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:padding="@dimen/stdpadding" - tools:context=".providersetup.AddProviderActivity" - tools:viewBindingIgnore="true" - > - - <LinearLayout - android:id="@+id/content" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" - android:layout_alignParentTop="true" - android:orientation="vertical"> - - <!-- the header contains the mask--> - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/text_uri_error" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="@dimen/activity_vertical_margin" - android:hint="@string/new_provider_uri" - app:errorEnabled="true"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/text_uri" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text" /> - - </com.google.android.material.textfield.TextInputLayout> - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="wrap_content"> - - <CheckBox - android:id="@+id/danger_checkbox" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" - android:visibility="gone" - android:layout_marginBottom="@dimen/add_button_margin" - /> - - <LinearLayout - android:id="@+id/button_container" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_alignParentRight="true" - android:layout_alignParentEnd="true" - android:gravity="right" - android:orientation="horizontal" - android:layout_below="@id/danger_checkbox"> - - <Button - android:id="@+id/button_cancel" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textColor="@color/color_font_btn_primary" - android:text="@string/cancel" /> - - <Button - android:id="@+id/button_save" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginLeft="@dimen/add_button_margin" - android:layout_marginStart="@dimen/add_button_margin" - android:enabled="false" - android:textColor="@color/color_font_btn_primary" - android:text="@string/save" /> - - </LinearLayout> - </RelativeLayout> - </LinearLayout> - -</RelativeLayout> diff --git a/app/src/main/res/layout/a_add_provider_tablet_scrollview.xml b/app/src/main/res/layout/a_add_provider_tablet_scrollview.xml deleted file mode 100644 index 74904f36..00000000 --- a/app/src/main/res/layout/a_add_provider_tablet_scrollview.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ScrollView android:orientation="vertical" - style="@style/BitmaskActivity" - android:layout_width="0dp" - android:layout_height="0dp" - app:layout_constraintBottom_toTopOf="@+id/guideline_bottom" - app:layout_constraintEnd_toStartOf="@+id/guideline_right" - app:layout_constraintHeight_min="411dp" - app:layout_constraintStart_toStartOf="@+id/guideline_left" - app:layout_constraintTop_toTopOf="@+id/guideline_top" - android:layout_margin="@dimen/stdpadding" - android:padding="@dimen/stdpadding" - android:background="@color/colorBackground" - android:isScrollContainer="true" - android:fadeScrollbars="false" - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - tools:viewBindingIgnore="true" - xmlns:tools="http://schemas.android.com/tools"> - - <LinearLayout - android:id="@+id/content" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/text_uri_error" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="@dimen/activity_vertical_margin" - android:hint="@string/new_provider_uri" - app:errorEnabled="true"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/text_uri" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text" /> - - </com.google.android.material.textfield.TextInputLayout> - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - > - <CheckBox - android:id="@+id/danger_checkbox" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:visibility="gone" - android:layout_marginBottom="@dimen/add_button_margin"/> - - <LinearLayout - android:id="@+id/button_container" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" - android:gravity="right" - android:orientation="horizontal" - android:layout_below="@+id/danger_checkbox" - > - - <Button - android:id="@+id/button_cancel" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:minWidth="80dp" - android:textColor="@color/color_font_btn_primary" - android:text="@string/cancel" /> - - <Button - android:id="@+id/button_save" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:minWidth="80dp" - android:layout_marginLeft="@dimen/add_button_margin" - android:layout_marginStart="@dimen/add_button_margin" - android:textColor="@color/color_font_btn_primary" - android:enabled="false" - android:text="@string/save" /> - </LinearLayout> - </RelativeLayout> - </LinearLayout> -</ScrollView>
\ No newline at end of file diff --git a/app/src/main/res/layout/a_custom_provider_setup.xml b/app/src/main/res/layout/a_custom_provider_setup.xml deleted file mode 100644 index 0e4e3edf..00000000 --- a/app/src/main/res/layout/a_custom_provider_setup.xml +++ /dev/null @@ -1,32 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/custom_provider_setup_layout" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.activities.CustomProviderSetupActivity" - android:padding="@dimen/stdpadding" - style="@style/BitmaskActivity" - tools:viewBindingIgnore="true" - > - - <!-- a "content" view that is required for - ConfigWizardBaseActivities --> - <LinearLayout - android:orientation="horizontal" - android:layout_height="0dp" - android:layout_width="0dp" - android:id="@id/content"> - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="visible" - /> - </LinearLayout> - - <include layout="@layout/v_loading_screen" - android:visibility="visible" - /> - -</LinearLayout> diff --git a/app/src/main/res/layout/a_custom_provider_setup_tablet_linear_layout.xml b/app/src/main/res/layout/a_custom_provider_setup_tablet_linear_layout.xml deleted file mode 100644 index 7e8cd51d..00000000 --- a/app/src/main/res/layout/a_custom_provider_setup_tablet_linear_layout.xml +++ /dev/null @@ -1,34 +0,0 @@ -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:layout_width="0dp" - android:layout_height="0dp" - android:layout_margin="@dimen/stdpadding" - android:padding="@dimen/stdpadding" - android:background="@color/colorBackground" - app:layout_constraintBottom_toTopOf="@+id/guideline_bottom" - app:layout_constraintEnd_toStartOf="@+id/guideline_right" - app:layout_constraintHeight_min="411dp" - app:layout_constraintStart_toStartOf="@+id/guideline_left" - app:layout_constraintTop_toTopOf="@+id/guideline_top" - tools:viewBindingIgnore="true"> - <!-- a "content" view that is required for - ConfigWizardBaseActivities --> - <LinearLayout - android:orientation="horizontal" - android:layout_height="0dp" - android:layout_width="0dp" - android:id="@id/content"> - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="visible" - /> - </LinearLayout> - - <include layout="@layout/v_loading_screen" - android:visibility="visible" - /> -</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/a_provider_credentials.xml b/app/src/main/res/layout/a_provider_credentials.xml deleted file mode 100644 index 033aae16..00000000 --- a/app/src/main/res/layout/a_provider_credentials.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:padding="@dimen/stdpadding" - style="@style/BitmaskActivity" - tools:viewBindingIgnore="true"> - - <include layout="@layout/v_loading_screen" /> - - <LinearLayout - android:id="@+id/content" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent" - > - - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - - <ScrollView - android:layout_height="match_parent" - android:layout_width="match_parent" - android:isScrollContainer="true" - > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - <include - layout="@layout/v_provider_credentials" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <androidx.appcompat.widget.AppCompatButton - android:id="@+id/button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="end" - android:enabled="false" - android:textColor="@color/color_font_btn_primary" - android:text="@string/login_button" /> - - </LinearLayout> - </ScrollView> - </LinearLayout> -</LinearLayout> diff --git a/app/src/main/res/layout/a_provider_credentials_tablet_linear_layout.xml b/app/src/main/res/layout/a_provider_credentials_tablet_linear_layout.xml deleted file mode 100644 index 73557853..00000000 --- a/app/src/main/res/layout/a_provider_credentials_tablet_linear_layout.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - style="@style/BitmaskActivity" - android:layout_width="0dp" - android:layout_height="0dp" - android:layout_margin="@dimen/stdpadding" - android:padding="@dimen/stdpadding" - android:background="@color/colorBackground" - app:layout_constraintBottom_toTopOf="@+id/guideline_bottom" - app:layout_constraintEnd_toStartOf="@+id/guideline_right" - app:layout_constraintHeight_min="411dp" - app:layout_constraintStart_toStartOf="@+id/guideline_left" - app:layout_constraintTop_toTopOf="@+id/guideline_top" - tools:viewBindingIgnore="true"> - - <include layout="@layout/v_loading_screen" /> - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="match_parent" - android:id="@+id/content" - android:orientation="vertical"> - - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - - <ScrollView - android:layout_height="match_parent" - android:layout_width="match_parent" - android:isScrollContainer="true" - > - - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - <include - layout="@layout/v_provider_credentials" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <androidx.appcompat.widget.AppCompatButton - android:id="@+id/button" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="end" - android:enabled="false" - android:textColor="@color/color_font_btn_primary" - android:text="@string/login_button" /> - - </LinearLayout> - </ScrollView> - </LinearLayout> -</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/a_provider_detail.xml b/app/src/main/res/layout/a_provider_detail.xml deleted file mode 100644 index 4a456c32..00000000 --- a/app/src/main/res/layout/a_provider_detail.xml +++ /dev/null @@ -1,43 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/provider_detail_fragment" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:padding="@dimen/stdpadding" - android:orientation="vertical" - style="@style/BitmaskActivity" - tools:viewBindingIgnore="true"> - - <include layout="@layout/v_loading_screen" /> - - <LinearLayout - android:id="@+id/content" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <androidx.appcompat.widget.AppCompatTextView - android:id="@+id/provider_detail_description" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textStyle="normal" - android:textAppearance="?android:attr/textAppearanceSmall" - android:layout_marginTop="@dimen/standard_margin" - android:layout_marginBottom="@dimen/standard_margin" - /> - - <ListView - android:id="@+id/provider_detail_options" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="@dimen/standard_margin" - android:drawSelectorOnTop="false"/> - - </LinearLayout> -</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/a_provider_detail_tablet_linear_layout.xml b/app/src/main/res/layout/a_provider_detail_tablet_linear_layout.xml deleted file mode 100644 index 5601a3d5..00000000 --- a/app/src/main/res/layout/a_provider_detail_tablet_linear_layout.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout android:orientation="vertical" - android:padding="@dimen/stdpadding" - style="@style/BitmaskActivity" - android:layout_width="0dp" - android:layout_height="0dp" - android:layout_margin="@dimen/stdpadding" - android:background="@color/colorBackground" - app:layout_constraintBottom_toTopOf="@+id/guideline_bottom" - app:layout_constraintEnd_toStartOf="@+id/guideline_right" - app:layout_constraintHeight_min="411dp" - app:layout_constraintStart_toStartOf="@+id/guideline_left" - app:layout_constraintTop_toTopOf="@+id/guideline_top" - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - tools:viewBindingIgnore="true" - xmlns:tools="http://schemas.android.com/tools"> - - <include layout="@layout/v_loading_screen" /> - - <LinearLayout - android:id="@+id/content" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - - <androidx.appcompat.widget.AppCompatTextView - android:id="@+id/provider_detail_description" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textStyle="normal" - android:textAppearance="?android:attr/textAppearanceMedium" - android:layout_marginTop="@dimen/standard_margin" - android:layout_marginBottom="@dimen/standard_margin" - /> - - <ListView - android:id="@+id/provider_detail_options" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="@dimen/list_view_margin_top" - android:drawSelectorOnTop="false" - /> - - </LinearLayout> -</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/a_provider_list.xml b/app/src/main/res/layout/a_provider_list.xml deleted file mode 100644 index 867d6d8d..00000000 --- a/app/src/main/res/layout/a_provider_list.xml +++ /dev/null @@ -1,34 +0,0 @@ -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/provider_list_layout" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".providersetup.ProviderListActivity" - android:padding="@dimen/stdpadding" - style="@style/BitmaskActivity" - tools:viewBindingIgnore="true"> - - <include layout="@layout/v_loading_screen" /> - - <LinearLayout - android:id="@+id/content" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:orientation="vertical"> - - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <ListView - android:id="@+id/provider_list" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:drawSelectorOnTop="false" - android:layout_marginTop="@dimen/standard_margin" - /> - - </LinearLayout> - -</RelativeLayout> diff --git a/app/src/main/res/layout/a_provider_list_tablet_linear_layout.xml b/app/src/main/res/layout/a_provider_list_tablet_linear_layout.xml deleted file mode 100644 index 67f82976..00000000 --- a/app/src/main/res/layout/a_provider_list_tablet_linear_layout.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout android:orientation="vertical" - android:padding="@dimen/stdpadding" - style="@style/BitmaskActivity" - android:layout_width="0dp" - android:layout_height="0dp" - android:layout_margin="@dimen/stdpadding" - android:background="@color/colorBackground" - app:layout_constraintBottom_toTopOf="@+id/guideline_bottom" - app:layout_constraintEnd_toStartOf="@+id/guideline_right" - app:layout_constraintHeight_min="411dp" - app:layout_constraintStart_toStartOf="@+id/guideline_left" - app:layout_constraintTop_toTopOf="@+id/guideline_top" - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - tools:viewBindingIgnore="true"> - - <include layout="@layout/v_loading_screen" /> - - <LinearLayout - android:id="@+id/content" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - - <se.leap.bitmaskclient.base.views.ProviderHeaderView - android:id="@+id/header" - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - - <ListView - android:id="@+id/provider_list" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:drawSelectorOnTop="false" - android:layout_marginTop="@dimen/list_view_margin_top" - /> - - </LinearLayout> -</LinearLayout>
\ No newline at end of file diff --git a/app/src/main/res/layout/d_checkbox_confirm.xml b/app/src/main/res/layout/d_checkbox_confirm.xml index d8811226..e55d5267 100644 --- a/app/src/main/res/layout/d_checkbox_confirm.xml +++ b/app/src/main/res/layout/d_checkbox_confirm.xml @@ -2,8 +2,7 @@ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - xmlns:tools="http://schemas.android.com/tools" - tools:viewBindingIgnore="true"> + xmlns:tools="http://schemas.android.com/tools"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" diff --git a/app/src/main/res/layout/d_list_selection.xml b/app/src/main/res/layout/d_list_selection.xml index 908c228f..6d87f1df 100644 --- a/app/src/main/res/layout/d_list_selection.xml +++ b/app/src/main/res/layout/d_list_selection.xml @@ -2,8 +2,7 @@ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - xmlns:tools="http://schemas.android.com/tools" - tools:viewBindingIgnore="true"> + xmlns:tools="http://schemas.android.com/tools"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" diff --git a/app/src/main/res/layout/donation_reminder_dialog.xml b/app/src/main/res/layout/donation_reminder_dialog.xml index 1260a99e..a4f3667a 100644 --- a/app/src/main/res/layout/donation_reminder_dialog.xml +++ b/app/src/main/res/layout/donation_reminder_dialog.xml @@ -4,8 +4,7 @@ android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - android:scrollbars="none" - tools:viewBindingIgnore="true"> + android:scrollbars="none"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" diff --git a/app/src/main/res/layout/f_about.xml b/app/src/main/res/layout/f_about.xml index e0193c1b..190ac758 100644 --- a/app/src/main/res/layout/f_about.xml +++ b/app/src/main/res/layout/f_about.xml @@ -1,3 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> + <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/aboutLayout" @@ -8,8 +10,7 @@ android:layout_marginStart="@dimen/stdpadding" android:layout_marginRight="@dimen/stdpadding" android:layout_marginEnd="@dimen/stdpadding" - tools:context=".base.MainActivity" - tools:viewBindingIgnore="true"> + tools:context=".base.MainActivity"> <LinearLayout android:layout_width="match_parent" diff --git a/app/src/main/res/layout/v_icon_select_text_list_item.xml b/app/src/main/res/layout/v_icon_select_text_list_item.xml index 60c5908c..46954b5e 100644 --- a/app/src/main/res/layout/v_icon_select_text_list_item.xml +++ b/app/src/main/res/layout/v_icon_select_text_list_item.xml @@ -1,10 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/item_container" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:layout_width="match_parent" android:orientation="horizontal" - xmlns:tools="http://schemas.android.com/tools" - tools:viewBindingIgnore="true"> + xmlns:tools="http://schemas.android.com/tools"> <androidx.appcompat.widget.AppCompatImageView android:id="@+id/material_icon" diff --git a/app/src/main/res/layout/v_provider_credentials.xml b/app/src/main/res/layout/v_provider_credentials.xml deleted file mode 100644 index 189bace6..00000000 --- a/app/src/main/res/layout/v_provider_credentials.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools"> - - <androidx.appcompat.widget.AppCompatTextView - android:id="@+id/provider_credentials_user_message" - android:layout_width="match_parent" - android:layout_height="wrap_content" - style="@style/TextAppearance.Design.Error" - android:visibility="gone" - android:linksClickable="true" - tools:viewBindingIgnore="true" - /> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/provider_credentials_username_error" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:hint="@string/auth_username" - app:errorEnabled="true" - android:layout_marginTop="@dimen/standard_margin" - app:errorTextAppearance="@style/error_appearance"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/provider_credentials_username" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ems="10" - android:inputType="text" /> - - </com.google.android.material.textfield.TextInputLayout> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/provider_credentials_password_error" - android:layout_width="match_parent" - android:layout_height="wrap_content" - app:passwordToggleEnabled="true" - android:hint="@string/password" - app:errorEnabled="true" - app:errorTextAppearance="@style/error_appearance"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/provider_credentials_password" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:inputType="textPassword" - /> - - </com.google.android.material.textfield.TextInputLayout> - - <com.google.android.material.textfield.TextInputLayout - android:id="@+id/provider_credentials_password_verification_error" - android:layout_width="match_parent" - android:layout_height="wrap_content" - app:passwordToggleEnabled="true" - android:hint="@string/password" - app:errorEnabled="true" - android:visibility="gone" - app:errorTextAppearance="@style/error_appearance"> - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/provider_credentials_password_verification" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:inputType="textPassword" - android:visibility="gone" - /> - - </com.google.android.material.textfield.TextInputLayout> -</merge>
\ No newline at end of file diff --git a/app/src/main/res/layout/v_provider_header.xml b/app/src/main/res/layout/v_provider_header.xml deleted file mode 100644 index 42f4f783..00000000 --- a/app/src/main/res/layout/v_provider_header.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_height="wrap_content" - android:layout_width="match_parent" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatImageView - android:id="@+id/provider_header_logo" - android:layout_width="@dimen/bitmask_logo" - android:layout_height="@dimen/bitmask_logo" - android:adjustViewBounds="true" - app:srcCompat="@drawable/logo" /> - - <androidx.appcompat.widget.AppCompatTextView - android:id="@+id/provider_header_text" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_below="@id/provider_header_logo" - android:text="" - android:ellipsize="end" - android:gravity="center_vertical" - android:textAppearance="@style/Base.TextAppearance.AppCompat.Headline" - android:layout_marginTop="@dimen/standard_margin" - android:layout_marginBottom="@dimen/standard_margin" - /> - -</RelativeLayout> diff --git a/app/src/main/res/layout/v_provider_list_item.xml b/app/src/main/res/layout/v_provider_list_item.xml deleted file mode 100644 index 0e7cc7f3..00000000 --- a/app/src/main/res/layout/v_provider_list_item.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:orientation="vertical" - android:paddingTop="2dip" - android:paddingBottom="2dip" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="?android:attr/activatedBackgroundIndicator" - android:minHeight="?android:attr/listPreferredItemHeight" - tools:viewBindingIgnore="true"> - - <androidx.appcompat.widget.AppCompatTextView android:id="@+id/provider_domain" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingStart="?android:attr/listPreferredItemPaddingStart" - android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" - android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" - android:paddingRight="?android:attr/listPreferredItemPaddingRight" - android:layout_marginTop="6dip" - android:textAppearance="?android:attr/textAppearanceListItem" - /> - - <androidx.appcompat.widget.AppCompatTextView android:id="@+id/provider_name" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingStart="?android:attr/listPreferredItemPaddingStart" - android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" - android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" - android:paddingRight="?android:attr/listPreferredItemPaddingRight" - android:textAppearance="?android:attr/textAppearanceSmall" - /> - -</LinearLayout> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 56588bc1..5bddd094 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -237,4 +237,5 @@ <string name="title_setup_success">You\'re all set!</string> <string name="setup_success_description">Click the button below to connect</string> <string name="permission_rejected">Permission request rejected.</string> + <string name="login_not_supported">The current app version doesn\'t support logins, which you need to update your VPN certificate for this provider.</string> </resources> diff --git a/app/src/production/java/se/leap/bitmaskclient/providersetup/AddProviderActivity.java b/app/src/production/java/se/leap/bitmaskclient/providersetup/AddProviderActivity.java deleted file mode 100644 index 7ca707db..00000000 --- a/app/src/production/java/se/leap/bitmaskclient/providersetup/AddProviderActivity.java +++ /dev/null @@ -1,36 +0,0 @@ -package se.leap.bitmaskclient.providersetup; - -import android.os.Bundle; -import android.view.View; -import android.widget.Button; - -import butterknife.BindView; -import se.leap.bitmaskclient.R; -import se.leap.bitmaskclient.providersetup.activities.AddProviderBaseActivity; - -public class AddProviderActivity extends AddProviderBaseActivity { - - final public static String TAG = "AddProviderActivity"; - - @BindView(R.id.button_save) - Button saveButton; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.a_add_provider); - init(); - - } - - - - @Override - public void setupSaveButton() { - saveButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - saveProvider(); - } - }); - } -} diff --git a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderDetailActivity.java b/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderDetailActivity.java deleted file mode 100644 index ec932394..00000000 --- a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderDetailActivity.java +++ /dev/null @@ -1,6 +0,0 @@ -package se.leap.bitmaskclient.providersetup; - -import se.leap.bitmaskclient.providersetup.activities.AbstractProviderDetailActivity; - -public class ProviderDetailActivity extends AbstractProviderDetailActivity { -} diff --git a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderListActivity.java b/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderListActivity.java deleted file mode 100644 index 6a1eaf95..00000000 --- a/app/src/production/java/se/leap/bitmaskclient/providersetup/ProviderListActivity.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2013 LEAP Encryption Access Project and contributers - * - * 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, see <http://www.gnu.org/licenses/>. - */ -package se.leap.bitmaskclient.providersetup; - -import androidx.annotation.NonNull; - -import se.leap.bitmaskclient.base.models.Provider; -import se.leap.bitmaskclient.providersetup.ProviderAPICommand; -import se.leap.bitmaskclient.providersetup.activities.ProviderListBaseActivity; - -import static se.leap.bitmaskclient.providersetup.ProviderAPI.SET_UP_PROVIDER; -import static se.leap.bitmaskclient.providersetup.ProviderSetupInterface.ProviderConfigState.SETTING_UP_PROVIDER; - -/** - * Activity that builds and shows the list of known available providers. - * <p/> - * It also allows the user to enter custom providers with a button. - * - * @author parmegv - * @author cyberta - */ -public class ProviderListActivity extends ProviderListBaseActivity { - - - @Override - protected void onItemSelectedLogic() { - setUpProvider(); - } - - /** - * Asks ProviderAPI to download a new provider.json file - * - */ - public void setUpProvider() { - providerConfigState = SETTING_UP_PROVIDER; - ProviderAPICommand.execute(this, SET_UP_PROVIDER, provider); - } - - @Override - public void retrySetUpProvider(@NonNull Provider provider) { - providerConfigState = SETTING_UP_PROVIDER; - ProviderAPICommand.execute(this, SET_UP_PROVIDER, provider); - } - -} diff --git a/app/src/production/res/layout-xlarge/d_new_provider.xml b/app/src/production/res/layout-xlarge/d_new_provider.xml deleted file mode 100644 index 6e64c8c0..00000000 --- a/app/src/production/res/layout-xlarge/d_new_provider.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - android:textSize="24sp" - tools:viewBindingIgnore="true" - > - - <EditText - android:id="@+id/new_provider_url" - android:inputType="textUri" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:layout_marginLeft="4dp" - android:layout_marginRight="4dp" - android:textSize="24sp" - android:hint="@string/new_provider_uri" /> - -</LinearLayout> diff --git a/app/src/production/res/layout/d_new_provider.xml b/app/src/production/res/layout/d_new_provider.xml deleted file mode 100644 index e58db08a..00000000 --- a/app/src/production/res/layout/d_new_provider.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - tools:viewBindingIgnore="true"> - - <EditText - android:id="@+id/new_provider_url" - android:inputType="textUri" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:layout_marginLeft="4dp" - android:layout_marginRight="4dp" - android:layout_marginBottom="4dp" - android:hint="@string/new_provider_uri" /> - -</LinearLayout> diff --git a/build.gradle b/build.gradle index 6fbe3207..aafc76c2 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:7.2.2' + classpath 'com.android.tools.build:gradle:8.1.2' } } diff --git a/gradle.properties b/gradle.properties index 44700ef5..a537ad3b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ android.enableJetifier=true android.useAndroidX=true org.gradle.jvmargs=-Xmx4096m -android.bundle.enableUncompressedNativeLibs = false
\ No newline at end of file +android.nonFinalResIds=false
\ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aaa09975..d50248b3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ #Sun Aug 07 23:06:29 CEST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip +distributionSha256Sum=7c3ad722e9b0ce8205b91560fd6ce8296ac3eadf065672242fd73c06b8eeb6ee distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/ics-openvpn b/ics-openvpn -Subproject 45f67a08b481f2f727556a36e28d17a3f68d435 +Subproject 14d655f2936be93b15c09278e91367f4e43890c diff --git a/scripts/build_deps.sh b/scripts/build_deps.sh index d1d42576..20ed016b 100755 --- a/scripts/build_deps.sh +++ b/scripts/build_deps.sh @@ -71,7 +71,7 @@ elif [[ $(ls -A ${DIR_OVPNASSETS}) && $(ls -A ${DIR_OVPNLIBS}) ]]; then else echo "Clean build: starting externalNativeBuild" cd ./ics-openvpn || quit "Directory ics-opevpn not found" - ./gradlew clean main:externalNativeBuildCleanSkeletonRelease main:externalNativeBuildSkeletonRelease --debug --stacktrace || quit "Build ics-openvpn native libraries failed" + ./gradlew clean main:externalNativeBuildCleanSkeletonOvpn2Release main:externalNativeBuildSkeletonOvpn2Release --debug --stacktrace || quit "Build ics-openvpn native libraries failed" ./gradlew --stop cd .. fi diff --git a/tor-android b/tor-android -Subproject 95697aef05cd97456f21cad087999efbe0501d1 +Subproject 5d7bc0b0bf97dd1f682b54ecaaecb3eb19d29ad |