fix some deprecations (#156)

Co-authored-by: mazm <marcel.zipaj-misko@student.tuke.sk>
This commit is contained in:
MZM 2021-11-17 23:32:56 +01:00 committed by emanuele-f
parent 3d5ce803a0
commit b330f5915d
3 changed files with 38 additions and 6 deletions

View File

@ -20,12 +20,15 @@
package com.emanuelef.remote_capture.activities;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
@ -55,9 +58,20 @@ public class CaptureCtrl extends AppCompatActivity {
private CtrlPermissions mPermissions;
@Override
@SuppressWarnings("deprecation")
protected void onCreate(@Nullable Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
final WindowInsetsController insetsController = getWindow().getInsetsController();
if (insetsController != null) {
insetsController.hide(WindowInsets.Type.statusBars());
}
} else {
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
}
getWindow().addFlags(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
super.onCreate(savedInstanceState);

View File

@ -21,6 +21,8 @@ package com.emanuelef.remote_capture.activities;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.InetAddresses;
import android.os.Build;
import android.os.Bundle;
import android.text.InputType;
import android.util.Patterns;
@ -117,12 +119,17 @@ public class SettingsActivity extends BaseActivity {
}
}
@SuppressWarnings("deprecation")
private void setupUdpExporterPrefs() {
/* Collector IP validation */
EditTextPreference mRemoteCollectorIp = findPreference(Prefs.PREF_COLLECTOR_IP_KEY);
mRemoteCollectorIp.setOnPreferenceChangeListener((preference, newValue) -> {
Matcher matcher = Patterns.IP_ADDRESS.matcher(newValue.toString());
return(matcher.matches());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
return (InetAddresses.isNumericAddress(newValue.toString()));
else {
Matcher matcher = Patterns.IP_ADDRESS.matcher(newValue.toString());
return(matcher.matches());
}
});
/* Collector port validation */
@ -182,6 +189,7 @@ public class SettingsActivity extends BaseActivity {
// Billing code here
}
@SuppressWarnings("deprecation")
private void setupSocks5ProxyPrefs() {
mProxyPrefs = findPreference("proxy_prefs");
mTlsHelp = findPreference("tls_how_to");
@ -195,8 +203,12 @@ public class SettingsActivity extends BaseActivity {
/* TLS Proxy IP validation */
mSocks5ProxyIp = findPreference(Prefs.PREF_SOCKS5_PROXY_IP_KEY);
mSocks5ProxyIp.setOnPreferenceChangeListener((preference, newValue) -> {
Matcher matcher = Patterns.IP_ADDRESS.matcher(newValue.toString());
return(matcher.matches());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
return (InetAddresses.isNumericAddress(newValue.toString()));
else {
Matcher matcher = Patterns.IP_ADDRESS.matcher(newValue.toString());
return(matcher.matches());
}
});
/* TLS Proxy port validation */

View File

@ -21,6 +21,7 @@ package com.emanuelef.remote_capture.adapters;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@ -100,6 +101,7 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.
mProtoAndPort = context.getString(R.string.proto_and_port);
}
@SuppressWarnings("deprecation")
public void bindConn(Context context, ConnectionDescriptor conn, AppsResolver apps, Drawable unknownIcon) {
AppDescriptor app = apps.get(conn.uid, 0);
Drawable appIcon;
@ -137,7 +139,11 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter.
color = R.color.statusClosed;
else
color = R.color.statusError;
statusInd.setTextColor(context.getResources().getColor(color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
statusInd.setTextColor(context.getResources().getColor(color, null));
else
statusInd.setTextColor(context.getResources().getColor(color));
if(conn.country.isEmpty())
countryCode.setText("");