Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/src/main/java/ohi/andre/consolelauncher/UIManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.net.ConnectivityManager;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.nfc.NfcAdapter;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Handler;
Expand Down Expand Up @@ -464,6 +465,11 @@ private class NetworkRunnable implements Runnable {
final Pattern b2 = Pattern.compile("%b2", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern b3 = Pattern.compile("%b3", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern b4 = Pattern.compile("%b4", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern nfc0 = Pattern.compile("%nfc0", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern nfc1 = Pattern.compile("%nfc1", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern nfc2 = Pattern.compile("%nfc2", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern nfc3 = Pattern.compile("%nfc3", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern nfc4 = Pattern.compile("%nfc4", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern ip4 = Pattern.compile("%ip4", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern ip6 = Pattern.compile("%ip6", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
final Pattern dt = Pattern.compile("%dt", Pattern.CASE_INSENSITIVE | Pattern.LITERAL);
Expand All @@ -479,6 +485,7 @@ private class NetworkRunnable implements Runnable {

WifiManager wifiManager;
BluetoothAdapter mBluetoothAdapter;
NfcAdapter mNfcAdapter;

ConnectivityManager connectivityManager;

Expand All @@ -502,6 +509,7 @@ public void run() {
connectivityManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
wifiManager = (WifiManager) mContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mNfcAdapter = NfcAdapter.getDefaultAdapter(mContext.getApplicationContext());

optionalValueSeparator = "\\" + XMLPrefsManager.get(Behavior.optional_values_separator);

Expand Down Expand Up @@ -549,6 +557,8 @@ public void run() {

// bluetooth
boolean bluetoothOn = mBluetoothAdapter != null && mBluetoothAdapter.isEnabled();
// nfc
boolean nfcOn = mNfcAdapter != null && mNfcAdapter.isEnabled();

String copy = format;

Expand All @@ -574,6 +584,11 @@ public void run() {
copy = b2.matcher(copy).replaceAll(bluetoothOn ? ON : OFF);
copy = b3.matcher(copy).replaceAll(bluetoothOn ? _true : _false);
copy = b4.matcher(copy).replaceAll(bluetoothOn ? TRUE : FALSE);
copy = nfc0.matcher(copy).replaceAll(nfcOn ? one : zero);
copy = nfc1.matcher(copy).replaceAll(nfcOn ? on : off);
copy = nfc2.matcher(copy).replaceAll(nfcOn ? ON : OFF);
copy = nfc3.matcher(copy).replaceAll(nfcOn ? _true : _false);
copy = nfc4.matcher(copy).replaceAll(nfcOn ? TRUE : FALSE);
copy = ip4.matcher(copy).replaceAll(NetworkUtils.getIPAddress(true));
copy = ip6.matcher(copy).replaceAll(NetworkUtils.getIPAddress(false));
copy = dt.matcher(copy).replaceAll(mobileType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ohi.andre.consolelauncher.commands.main.raw;

import android.bluetooth.BluetoothAdapter;
import android.nfc.NfcAdapter;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
Expand Down Expand Up @@ -99,6 +100,13 @@ public String exec(ExecutePack pack) {
.append(info.res.getString(R.string.location_label)).append(Tuils.SPACE).append(gps_enabled || network_enabled).append(Tuils.NEWLINE)
.append(info.res.getString(R.string.brightness_label)).append(Tuils.SPACE).append(autobrightnessState == SCREEN_BRIGHTNESS_MODE_AUTOMATIC ? "(auto) " : Tuils.EMPTYSTRING).append(b).append("%");

// nfc
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(info.context.getApplicationContext());

if(nfcAdapter != null) {
builder.append(Tuils.NEWLINE).append(info.res.getString(R.string.nfc_label)).append(Tuils.SPACE).append( nfcAdapter.isEnabled());
}

return builder.toString();
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
<string name="location_label">Location:</string>
<string name="brightness_label">Brightness:</string>
<string name="bluetooth_label">Bluetooth:</string>
<string name="nfc_label">NFC:</string>

<!-- contacts -->
<string name="sms_hint">write your SMS or nothing to cancel</string>
Expand Down