mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-27 13:21:30 +00:00
Replaced deprecated methods
This commit is contained in:
parent
d8a05ed392
commit
336aec5251
8 changed files with 18 additions and 13 deletions
|
@ -12,6 +12,7 @@ import android.os.Bundle;
|
|||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -236,7 +237,7 @@ public class FolderPickerActivity extends SyncthingActivity
|
|||
int textColor = (f.isDirectory())
|
||||
? android.R.color.primary_text_light
|
||||
: android.R.color.tertiary_text_light;
|
||||
title.setTextColor(getContext().getResources().getColor(textColor));
|
||||
title.setTextColor(ContextCompat.getColor(getContext(), textColor));
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ public class MainActivity extends SyncthingActivity
|
|||
.commit();
|
||||
mDrawerToggle = new Toggle(this, mDrawerLayout);
|
||||
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||
mDrawerLayout.addDrawerListener(mDrawerToggle);
|
||||
setOptimalDrawerWidth(findViewById(R.id.drawer));
|
||||
|
||||
onNewIntent(getIntent());
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.app.AlertDialog;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -161,9 +162,9 @@ public class DrawerFragment extends Fragment implements RestApi.OnReceiveSystemI
|
|||
mAnnounceServer.setText(Integer.toString(info.extAnnounceConnected) + "/" +
|
||||
Integer.toString(info.extAnnounceTotal));
|
||||
if (info.extAnnounceConnected > 0) {
|
||||
mAnnounceServer.setTextColor(getResources().getColor(R.color.text_green));
|
||||
mAnnounceServer.setTextColor(ContextCompat.getColor(getContext(), R.color.text_green));
|
||||
} else {
|
||||
mAnnounceServer.setTextColor(getResources().getColor(R.color.text_red));
|
||||
mAnnounceServer.setTextColor(ContextCompat.getColor(getContext(), R.color.text_red));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
|
@ -53,7 +54,8 @@ public class DeviceStateHolder extends BroadcastReceiver {
|
|||
mContext = context;
|
||||
ConnectivityManager cm = (ConnectivityManager)
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
mIsWifiConnected = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
|
||||
NetworkInfo ni = cm.getActiveNetworkInfo();
|
||||
mIsWifiConnected = ni != null && ni.getType() == ConnectivityManager.TYPE_WIFI && ni.isConnected();
|
||||
if (android.os.Build.VERSION.SDK_INT >= 16 && cm.isActiveNetworkMetered())
|
||||
mIsWifiConnected = false;
|
||||
if (mIsWifiConnected) {
|
||||
|
|
|
@ -24,8 +24,8 @@ public class NetworkReceiver extends BroadcastReceiver {
|
|||
|
||||
ConnectivityManager cm =
|
||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo wifiInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
boolean isWifiConnected = wifiInfo != null && wifiInfo.isConnected();
|
||||
NetworkInfo ni = cm.getActiveNetworkInfo();
|
||||
boolean isWifiConnected = ni != null && ni.getType() == ConnectivityManager.TYPE_WIFI && ni.isConnected();
|
||||
Log.v(TAG, "Received wifi " + (isWifiConnected ? "connected" : "disconnected") + " event");
|
||||
Intent i = new Intent(context, SyncthingService.class);
|
||||
i.putExtra(DeviceStateHolder.EXTRA_HAS_WIFI, isWifiConnected);
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.nutomic.syncthingandroid.syncthing;
|
|||
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
|
||||
import com.nutomic.syncthingandroid.util.Https;
|
||||
|
||||
|
@ -53,7 +52,7 @@ public abstract class PollWebGuiAvailableTask extends AsyncTask<String, Void, Vo
|
|||
// We catch this in every call, as long as the service is not online,
|
||||
// so we ignore and continue.
|
||||
} catch (IOException|InterruptedException|IllegalArgumentException e) {
|
||||
Log.w(TAG, "Failed to poll for web interface", e);
|
||||
//Log.w(TAG, "Failed to poll for web interface", e);
|
||||
}
|
||||
} while (status != HttpStatus.SC_OK && status != HttpStatus.SC_UNAUTHORIZED);
|
||||
return null;
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.nutomic.syncthingandroid.util;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -48,11 +49,11 @@ public class DevicesAdapter extends ArrayAdapter<RestApi.Device>
|
|||
if (conn != null && conn.connected) {
|
||||
if (conn.completion == 100) {
|
||||
status.setText(r.getString(R.string.device_up_to_date));
|
||||
status.setTextColor(r.getColor(R.color.text_green));
|
||||
status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_green));
|
||||
}
|
||||
else {
|
||||
status.setText(r.getString(R.string.device_syncing, conn.completion));
|
||||
status.setTextColor(r.getColor(R.color.text_blue));
|
||||
status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_blue));
|
||||
}
|
||||
download.setText(RestApi.readableTransferRate(getContext(), conn.inBits));
|
||||
upload.setText(RestApi.readableTransferRate(getContext(), conn.outBits));
|
||||
|
@ -61,7 +62,7 @@ public class DevicesAdapter extends ArrayAdapter<RestApi.Device>
|
|||
download.setText(RestApi.readableTransferRate(getContext(), 0));
|
||||
upload.setText(RestApi.readableTransferRate(getContext(), 0));
|
||||
status.setText(r.getString(R.string.device_disconnected));
|
||||
status.setTextColor(r.getColor(R.color.text_red));
|
||||
status.setTextColor(ContextCompat.getColor(getContext(), R.color.text_red));
|
||||
}
|
||||
|
||||
return convertView;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.nutomic.syncthingandroid.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -47,7 +48,7 @@ public class FoldersAdapter extends ArrayAdapter<RestApi.Folder>
|
|||
RestApi.Folder folder = getItem(position);
|
||||
RestApi.Model model = mModels.get(folder.id);
|
||||
label.setText(TextUtils.isEmpty(folder.label) ? folder.id : folder.label);
|
||||
state.setTextColor(getContext().getResources().getColor(R.color.text_green));
|
||||
state.setTextColor(ContextCompat.getColor(getContext(), R.color.text_green));
|
||||
directory.setText(folder.path);
|
||||
if (model != null) {
|
||||
int percentage = (model.globalBytes != 0)
|
||||
|
|
Loading…
Reference in a new issue