diff --git a/app/src/main/java/eu/faircode/netguard/ActivityMain.java b/app/src/main/java/eu/faircode/netguard/ActivityMain.java
index 5667439f..7188337f 100644
--- a/app/src/main/java/eu/faircode/netguard/ActivityMain.java
+++ b/app/src/main/java/eu/faircode/netguard/ActivityMain.java
@@ -46,6 +46,7 @@ import android.support.v7.widget.SwitchCompat;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.util.TypedValue;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -53,6 +54,7 @@ import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
+import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
@@ -63,6 +65,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
private boolean running = false;
private SwitchCompat swEnabled;
+ private ImageView ivMetered;
private SwipeRefreshLayout swipeRefresh;
private AdapterRule adapter = null;
private MenuItem menuSearch = null;
@@ -116,9 +119,12 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
SinkholeService.stop("UI", this);
}
+ getSupportActionBar().setTitle(null);
+
// Action bar
- View actionView = getLayoutInflater().inflate(R.layout.action, null, false);
+ final View actionView = getLayoutInflater().inflate(R.layout.action, null, false);
swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled);
+ ivMetered = (ImageView) actionView.findViewById(R.id.ivMetered);
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setCustomView(actionView);
@@ -180,6 +186,17 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
}
});
+ // Network is metered
+ ivMetered.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_metered, Toast.LENGTH_LONG);
+ toast.setGravity(Gravity.TOP, actionView.getLeft(), actionView.getBottom());
+ toast.show();
+ return true;
+ }
+ });
+
// Disabled warning
TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled);
tvDisabled.setVisibility(enabled ? View.GONE : View.VISIBLE);
@@ -465,7 +482,9 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
Util.logExtras(intent);
if (adapter != null)
- if (intent.hasExtra("connected") && intent.hasExtra("metered"))
+ if (intent.hasExtra("connected") && intent.hasExtra("metered")) {
+ ivMetered.setVisibility(Util.isMeteredNetwork(ActivityMain.this) ? View.VISIBLE : View.GONE);
+
if (intent.getBooleanExtra("connected", false))
if (intent.getBooleanExtra("metered", false))
adapter.setMobileActive();
@@ -473,7 +492,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
adapter.setWifiActive();
else
adapter.setDisconnected();
- else
+ } else
updateApplicationList(null);
}
};
diff --git a/app/src/main/res/drawable-hdpi/ic_attach_money_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_attach_money_white_24dp.png
new file mode 100644
index 00000000..ee833c66
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_attach_money_white_24dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_attach_money_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_attach_money_white_24dp.png
new file mode 100644
index 00000000..707d1676
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_attach_money_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_attach_money_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_attach_money_white_24dp.png
new file mode 100644
index 00000000..20efc6cb
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_attach_money_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_attach_money_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_attach_money_white_24dp.png
new file mode 100644
index 00000000..d4bde813
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_attach_money_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_attach_money_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_attach_money_white_24dp.png
new file mode 100644
index 00000000..f3c56854
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_attach_money_white_24dp.png differ
diff --git a/app/src/main/res/layout/action.xml b/app/src/main/res/layout/action.xml
index 474fa39c..b3425ff5 100644
--- a/app/src/main/res/layout/action.xml
+++ b/app/src/main/res/layout/action.xml
@@ -4,12 +4,28 @@
android:background="?attr/colorPrimary"
android:orientation="horizontal">
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a3e83f60..aba1fda6 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -162,6 +162,7 @@ Your internet traffic is not being sent to a remote VPN server.
Last download: %s
Start forwarding from %1$s port %2$d to %3$s:%4$d of \'%5$s\'?
Stop forwarding of %1$s port %2$d?
+ Network is metered
Conditions
Allow Wi-Fi when screen is on