Skip to content

Commit

Permalink
add ignore nfc tag id, and moved on to 0.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
theScrabi committed Mar 31, 2016
1 parent c8c5e1f commit b86a830
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ android {
applicationId "org.schabi.terminightor"
minSdkVersion 15
targetSdkVersion 23
versionCode 6
versionCode 7

versionName "0.9.4"
versionName "0.9.5"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.View;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class NightKillerActivity extends Activity {
private ImageView innerWave;
private ImageView outerWave;
private boolean hasStopped = false;
private boolean ignoreNfcTagId = false;

private NfcAdapter nfcAdapter;
private long alarmId = -1;
Expand Down Expand Up @@ -111,6 +113,9 @@ public void onCreate(Bundle savedInstanceState) {

nfcAdapter = NfcAdapter.getDefaultAdapter(this);

ignoreNfcTagId = PreferenceManager.getDefaultSharedPreferences(this)
.getBoolean(this.getString(R.string.ignoreNfcId), false);

Log.d(TAG, Long.toString(alarmId));
}

Expand Down Expand Up @@ -145,7 +150,7 @@ public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
byte[] nfcId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
if(nfcId != null) {
if (Arrays.equals(nfcId, expectedNfcId)) {
if (Arrays.equals(nfcId, expectedNfcId) || ignoreNfcTagId) {
Log.d(TAG, "Send kill alarm");
Intent killAlarmIntent = new Intent(NightKillerService.ACTION_KILL_ALARM);
LocalBroadcastManager.getInstance(this).sendBroadcast(killAlarmIntent);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/settings_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<resources>
<string name="use24Hours">use_24_hours</string>
<string name="overrideAlarmVolume">override_alarm_volume</string>
<string name="ignoreNfcId">ignore_nfc_id</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@
<string name="unlockInfoText">Unlock screen, and enable NFC.</string>
<string name="defaultRingTone">Default</string>
<string name="alarmSaved">Alarm Saved</string>
<string name="ignoreNfcTagIdTitle">Ignore NFC tag ID</string>
<string name="ignoreNfcTagIdSummary">If this is set NewPipe will not check the ID of an Nfc tag, when switching an alarm off.</string>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/xml/settings_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
android:summary="@string/overrideAlarmVolumeDescription"
android:defaultValue="false"/>

<CheckBoxPreference
android:key="@string/ignoreNfcId"
android:title="@string/ignoreNfcTagIdTitle"
android:summary="@string/ignoreNfcTagIdSummary"
android:defaultValue="false"/>

</PreferenceScreen>

0 comments on commit b86a830

Please sign in to comment.