mirror of
https://github.com/etesync/android
synced 2024-12-23 15:18:14 +00:00
Add a way to view own fingerprint.
This adds a menu option from the account page to view your own keypair (to compare when sharing).
This commit is contained in:
parent
4c6176a6f4
commit
4246ae7ede
@ -49,10 +49,12 @@ import android.widget.PopupMenu;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.etesync.syncadapter.AccountSettings;
|
||||
import com.etesync.syncadapter.AccountUpdateService;
|
||||
import com.etesync.syncadapter.App;
|
||||
import com.etesync.syncadapter.Constants;
|
||||
import com.etesync.syncadapter.R;
|
||||
import com.etesync.syncadapter.journalmanager.Crypto;
|
||||
import com.etesync.syncadapter.model.CollectionInfo;
|
||||
import com.etesync.syncadapter.model.JournalEntity;
|
||||
import com.etesync.syncadapter.model.ServiceEntity;
|
||||
@ -61,6 +63,8 @@ import com.etesync.syncadapter.ui.setup.SetupUserInfoFragment;
|
||||
import com.etesync.syncadapter.utils.HintManager;
|
||||
import com.etesync.syncadapter.utils.ShowcaseBuilder;
|
||||
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@ -167,6 +171,19 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
|
||||
})
|
||||
.show();
|
||||
break;
|
||||
case R.id.show_fingerprint:
|
||||
AlertDialog dialog = new AlertDialog.Builder(AccountActivity.this)
|
||||
.setIcon(R.drawable.ic_fingerprint_dark)
|
||||
.setTitle(R.string.show_fingperprint_title)
|
||||
.setMessage(getFormattedFingerprint())
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
}).create();
|
||||
dialog.show();
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@ -196,6 +213,19 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
|
||||
}
|
||||
};
|
||||
|
||||
private String getFormattedFingerprint() {
|
||||
AccountSettings settings = null;
|
||||
try {
|
||||
settings = new AccountSettings(this, account);
|
||||
byte[] fingerprint = Crypto.AsymmetricCryptoManager.getKeyFingerprint(settings.getKeyPair().getPublicKey());
|
||||
String fingerprintString = Hex.toHexString(fingerprint).toLowerCase();
|
||||
return fingerprintString.replaceAll("(.{4})", "$1 ");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* LOADERS AND LOADED DATA */
|
||||
|
||||
protected static class AccountInfo {
|
||||
|
5
app/src/main/res/drawable/ic_fingerprint_dark.xml
Normal file
5
app/src/main/res/drawable/ic_fingerprint_dark.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:alpha="0.54" android:height="24dp"
|
||||
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF000000" android:pathData="M11.83,1.73C8.43,1.79 6.23,3.32 6.23,3.32C5.95,3.5 5.88,3.91 6.07,4.19C6.27,4.5 6.66,4.55 6.96,4.34C6.96,4.34 11.27,1.15 17.46,4.38C17.75,4.55 18.14,4.45 18.31,4.15C18.5,3.85 18.37,3.47 18.03,3.28C16.36,2.4 14.78,1.96 13.36,1.8C12.83,1.74 12.32,1.72 11.83,1.73M12.22,4.34C6.26,4.26 3.41,9.05 3.41,9.05C3.22,9.34 3.3,9.72 3.58,9.91C3.87,10.1 4.26,10 4.5,9.68C4.5,9.68 6.92,5.5 12.2,5.59C17.5,5.66 19.82,9.65 19.82,9.65C20,9.94 20.38,10.04 20.68,9.87C21,9.69 21.07,9.31 20.9,9C20.9,9 18.15,4.42 12.22,4.34M11.5,6.82C9.82,6.94 8.21,7.55 7,8.56C4.62,10.53 3.1,14.14 4.77,19C4.88,19.33 5.24,19.5 5.57,19.39C5.89,19.28 6.07,18.92 5.95,18.6V18.6C4.41,14.13 5.78,11.2 7.8,9.5C9.77,7.89 13.25,7.5 15.84,9.1C17.11,9.9 18.1,11.28 18.6,12.64C19.11,14 19.08,15.32 18.67,15.94C18.25,16.59 17.4,16.83 16.65,16.64C15.9,16.45 15.29,15.91 15.26,14.77C15.23,13.06 13.89,12 12.5,11.84C11.16,11.68 9.61,12.4 9.21,14C8.45,16.92 10.36,21.07 14.78,22.45C15.11,22.55 15.46,22.37 15.57,22.04C15.67,21.71 15.5,21.35 15.15,21.25C11.32,20.06 9.87,16.43 10.42,14.29C10.66,13.33 11.5,13 12.38,13.08C13.25,13.18 14,13.7 14,14.79C14.05,16.43 15.12,17.54 16.34,17.85C17.56,18.16 18.97,17.77 19.72,16.62C20.5,15.45 20.37,13.8 19.78,12.21C19.18,10.61 18.07,9.03 16.5,8.04C14.96,7.08 13.19,6.7 11.5,6.82M11.86,9.25V9.26C10.08,9.32 8.3,10.24 7.28,12.18C5.96,14.67 6.56,17.21 7.44,19.04C8.33,20.88 9.54,22.1 9.54,22.1C9.78,22.35 10.17,22.35 10.42,22.11C10.67,21.87 10.67,21.5 10.43,21.23C10.43,21.23 9.36,20.13 8.57,18.5C7.78,16.87 7.3,14.81 8.38,12.77C9.5,10.67 11.5,10.16 13.26,10.67C15.04,11.19 16.53,12.74 16.5,15.03C16.46,15.38 16.71,15.68 17.06,15.7C17.4,15.73 17.7,15.47 17.73,15.06C17.79,12.2 15.87,10.13 13.61,9.47C13.04,9.31 12.45,9.23 11.86,9.25M12.08,14.25C11.73,14.26 11.46,14.55 11.47,14.89C11.47,14.89 11.5,16.37 12.31,17.8C13.15,19.23 14.93,20.59 18.03,20.3C18.37,20.28 18.64,20 18.62,19.64C18.6,19.29 18.3,19.03 17.91,19.06C15.19,19.31 14.04,18.28 13.39,17.17C12.74,16.07 12.72,14.88 12.72,14.88C12.72,14.53 12.44,14.25 12.08,14.25Z"/>
|
||||
</vector>
|
@ -20,6 +20,11 @@
|
||||
android:title="@string/account_settings"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item android:id="@+id/show_fingerprint"
|
||||
android:icon="@drawable/ic_fingerprint_dark"
|
||||
android:title="@string/account_show_fingerprint"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item android:id="@+id/delete_account"
|
||||
android:title="@string/account_delete"
|
||||
app:showAsAction="never"/>
|
||||
|
@ -90,6 +90,7 @@
|
||||
<string name="account_synchronizing_now">Synchronizing now</string>
|
||||
<string name="account_settings">Account settings</string>
|
||||
<string name="account_delete">Delete account</string>
|
||||
<string name="account_show_fingerprint">Show Fingerprint</string>
|
||||
<string name="account_delete_confirmation_title">Really delete account?</string>
|
||||
<string name="account_delete_confirmation_text">All local copies of address books, calendars and task lists will be deleted.</string>
|
||||
<string name="account_create_new_calendar">Create new calendar</string>
|
||||
@ -97,6 +98,8 @@
|
||||
<string name="account_delete_collection_last_text">Deleting the last collection is not allowed, please create a new one if you\'d like to delete this one.</string>
|
||||
<string name="account_showcase_view_collection">You can click on an item to view the collection. From there you can view the journal, import, and much more...</string>
|
||||
|
||||
<string name="show_fingperprint_title">My Fingerprint</string>
|
||||
|
||||
<!-- ViewCollection -->
|
||||
<string name="change_journal_title">Change Journal</string>
|
||||
<string name="account_showcase_import">In order to import contacts and calendars into EteSync, you need to click on the menu, and choose \"Import\".</string>
|
||||
|
Loading…
Reference in New Issue
Block a user