Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4345a00a authored by Felix Bechstein's avatar Felix Bechstein Committed by Steve Kondik
Browse files

Add multiple UUID tags to profile (2/2 Settings)

Adding multiple UUID tags to a profile allows us to share a single NFC tag across multiple devices.

NFC tag writing works as before.
NFC tag reading is expanded to check the UUID and the UUID tags of a profile.

When reading unknown profiles, the user is asked to attach the tag to an exising profile.
The NFC tag itself stays untouched.

Patch Set 1:
* initial patch

Patch Set 2:
* change wording

Patch Set 3:
* add toast after attaching tag to profile

Patch Set 4:
* rebase
* adapt to Framework Patch Set 2

Patch Set 5:
* fix German strings

Patch Set 6:
* cleanup
* remove redundant if clause

Patch Set 7:
* cleanup imports (sorry for the commit spam)

Change-Id: I593240570772013ded263352421d51be6a6d0415
parent e265095e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1389,6 +1389,8 @@

        <activity android:name=".profiles.NFCProfileWriter" />

        <activity android:name=".profiles.NFCProfileSelect" />

        <activity android:name=".cyanogenmod.LockscreenTargets" />

        <activity android:name=".cyanogenmod.LockscreenInterface" />
+49 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The CyanogenMod Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:gravity="center">

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_centerInParent="true">

        <TextView
            style="?android:attr/textAppearanceMedium"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="30dip"
            android:layout_marginRight="30dip"
            android:layout_marginBottom="30dip"
            android:layout_gravity="center"
            android:text="@string/profile_add_nfc_text" />

        <Button android:id="@+id/add_tag"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="12dip"
            android:layout_gravity="center"
            android:text="@string/profile_select" />

    </LinearLayout>
</RelativeLayout>
+3 −0
Original line number Diff line number Diff line
@@ -2074,6 +2074,9 @@ ice shows the slider widgets before the unlock option [CHAR LIMIT=28]-->
    <string name="profile_write_failed">Schreiben des Tags fehlgeschlagen!</string>
    <string name="profile_selected">Profil %1$s aktiviert</string>
    <string name="profile_nfc_text">Nach Verknüpfen eines Profils mit einem NFC-Tag aktiviert ein Berühren des Geräts mit diesem Tag das entsprechende Profil. Eine weitere Berührung aktiviert das vorherige Profil.</string>
    <string name="profile_unknown_nfc_tag">Unbekanntes Profil</string>
    <string name="profile_add_nfc_text">Das NFC-Tag verweist auf ein unbekanntes Profil. Das Verknüpfen des NFC-Tags mit einem existierenden Profil ermöglicht es, das entsprechende Profil in Zukunft durch eine Berührung zu aktivieren.</string>
    <string name="profile_select">Profil auswählen</string>

    <!-- Connection override toggles (not all are used at this time ) -->
    <string name="possibleButtons">Mögliche Tasten</string> <!-- UNUSED -->
+4 −1
Original line number Diff line number Diff line
@@ -4480,7 +4480,10 @@ found in the list of installed apps.</string>
    <string name="profile_write_success">Tag successfully written</string>
    <string name="profile_write_failed">Tag writing failed!</string>
    <string name="profile_selected">Profile selected: %1$s</string>
    <string name="profile_nfc_text">Writing a profile to an NFC tag allows you to tap the tag to select that profile. Tapping a second time will select the previously selected profile.</string>
    <string name="profile_nfc_text">Writing a profile to a NFC tag allows for tapping the tag to select the profile. Tapping a second time will select the previously selected profile.</string>
    <string name="profile_unknown_nfc_tag">Unknown profile</string>
    <string name="profile_add_nfc_text">This NFC tag refers to an unknown profile. Attaching this NFC tag to an existing profile will allow for selecting the profile in the future.</string>
    <string name="profile_select">Select profile</string>

    <!-- Stylus Icon -->
    <string name="stylus_icon_enabled_title">Show icon when using stylus</string>
+19 −8
Original line number Diff line number Diff line
@@ -85,10 +85,20 @@ public class NFCProfile extends Activity {
        UUID profileUuid = NFCProfileUtils.toUUID(payload);
        Profile currentProfile = mProfileManager.getActiveProfile();

        Profile targetProfile = mProfileManager.getProfile(profileUuid);

        if (targetProfile == null) {
            // show profile selection for unknown tag
            Intent i = new Intent(this, NFCProfileSelect.class);
            i.putExtra(NFCProfileSelect.EXTRA_PROFILE_UUID, profileUuid.toString());
            i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            this.startActivity(i);
        } else {
            // switch to profile
            if (currentProfile == null || !currentProfile.getUuid().equals(profileUuid)) {
                saveCurrentProfile();
                switchTo(profileUuid);
        } else if (currentProfile.getUuid().equals(profileUuid)) {
            } else {
                Profile lastProfile = getPreviouslySelectedProfile();
                if (lastProfile != null) {
                    switchTo(lastProfile.getUuid());
@@ -96,6 +106,7 @@ public class NFCProfile extends Activity {
                }
            }
        }
    }

    private void switchTo(UUID uuid) {
        Profile p = mProfileManager.getProfile(uuid);
Loading