Add permissions request, comment out debug print statements.
This commit is contained in:
parent
a1d9ffa6c6
commit
23df75fd15
|
@ -27,6 +27,8 @@ import android.content.IntentSender;
|
||||||
import android.content.IntentSender.OnFinished;
|
import android.content.IntentSender.OnFinished;
|
||||||
import android.content.IntentSender.SendIntentException;
|
import android.content.IntentSender.SendIntentException;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
|
||||||
public class PgpConnect extends Fragment {
|
public class PgpConnect extends Fragment {
|
||||||
Activity act;
|
Activity act;
|
||||||
|
@ -34,6 +36,7 @@ public class PgpConnect extends Fragment {
|
||||||
Handler handler;
|
Handler handler;
|
||||||
OpenPgpServiceConnection mServiceConnection;
|
OpenPgpServiceConnection mServiceConnection;
|
||||||
ClipboardManager cb;
|
ClipboardManager cb;
|
||||||
|
final int PERMISSIONS_REQUEST = 1;
|
||||||
|
|
||||||
public PgpConnect(Activity act) {
|
public PgpConnect(Activity act) {
|
||||||
Log.d("gio", "PgpConnect(Activity)");
|
Log.d("gio", "PgpConnect(Activity)");
|
||||||
|
@ -49,6 +52,10 @@ public class PgpConnect extends Fragment {
|
||||||
FragmentTransaction ft = fm.beginTransaction();
|
FragmentTransaction ft = fm.beginTransaction();
|
||||||
ft.add(frag, "PgpConnect");
|
ft.add(frag, "PgpConnect");
|
||||||
ft.commitNow();
|
ft.commitNow();
|
||||||
|
|
||||||
|
if (ctx.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ctx.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSIONS_REQUEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -160,7 +167,7 @@ public class PgpConnect extends Fragment {
|
||||||
Log.d("gio","_getid: success");
|
Log.d("gio","_getid: success");
|
||||||
try {
|
try {
|
||||||
String ret = os.toString("UTF-8");
|
String ret = os.toString("UTF-8");
|
||||||
Log.d(OpenPgpApi.TAG, "output: " + ret);
|
//Log.d(OpenPgpApi.TAG, "output: " + ret);
|
||||||
stringResult(chint, ret);
|
stringResult(chint, ret);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
Log.e("gio", "UnsupportedEncodingException", e);
|
Log.e("gio", "UnsupportedEncodingException", e);
|
||||||
|
@ -197,7 +204,7 @@ public class PgpConnect extends Fragment {
|
||||||
case OpenPgpApi.RESULT_CODE_SUCCESS: {
|
case OpenPgpApi.RESULT_CODE_SUCCESS: {
|
||||||
try {
|
try {
|
||||||
String ret = os.toString("UTF-8");
|
String ret = os.toString("UTF-8");
|
||||||
Log.d(OpenPgpApi.TAG, "output: " + ret);
|
//Log.d(OpenPgpApi.TAG, "output: " + ret);
|
||||||
stringResult(chint, ret);
|
stringResult(chint, ret);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
Log.e("gio", "UnsupportedEncodingException", e);
|
Log.e("gio", "UnsupportedEncodingException", e);
|
||||||
|
|
|
@ -77,18 +77,18 @@ func (s *Store) nativeDecrypt(name string) (string, error) {
|
||||||
return "", fmt.Errorf("Error reading file: %s", err)
|
return "", fmt.Errorf("Error reading file: %s", err)
|
||||||
}
|
}
|
||||||
ret, err := pgp.Decrypt(string(data))
|
ret, err := pgp.Decrypt(string(data))
|
||||||
log.Printf("nativeDecrypt(): got %s", ret)
|
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) nativeEncrypt(pw string) ([]byte, error) {
|
func (s *Store) nativeEncrypt(pw string) ([]byte, error) {
|
||||||
connect()
|
connect()
|
||||||
ret, err := pgp.Encrypt(s.Id, pw)
|
ret, err := pgp.Encrypt(s.Id, pw)
|
||||||
log.Printf("nativeEncrypt(): got %s", ret)
|
|
||||||
return []byte(ret), err
|
return []byte(ret), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func nativeIdentities() ([]string, error) {
|
func nativeIdentities() ([]string, error) {
|
||||||
|
//NOT IMPLEMENTED ON ANDROID
|
||||||
|
return []string{}, nil
|
||||||
log.Printf("nativeIdentities()")
|
log.Printf("nativeIdentities()")
|
||||||
connect()
|
connect()
|
||||||
log.Printf("calling pgp.GetId()")
|
log.Printf("calling pgp.GetId()")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user