diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
index 95fff3ff..df817b82 100755
--- a/android/AndroidManifest.xml
+++ b/android/AndroidManifest.xml
@@ -6,21 +6,21 @@
android:versionName="2.18.0">
-
-
-
+
+
+
-
+
+
diff --git a/android/build.gradle b/android/build.gradle
index 821dbc16..750ae008 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,15 +1,31 @@
buildscript {
repositories {
- mavenCentral()
- jcenter()
+ mavenCentral()
+ jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.3.3'
+ classpath 'com.android.tools.build:gradle:2.3.3'
}
}
apply plugin: 'com.android.application'
+repositories {
+ jcenter()
+ maven {
+ url 'https://maven.google.com'
+ }
+}
+
+dependencies {
+// compile "com.android.support:support-v4:26.1.0"
+// compile "com.android.support:support-v13:26.1.0"
+// compile "com.android.support:cardview-v7:26.1.0"
+// compile "com.android.support:appcompat-v7:26.1.0"
+ compile 'com.android.support:support-v4:25.3.1'
+ compile 'com.android.support:design:25.3.1'
+}
+
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
diff --git a/android/res/layout/activity_perms_asker.xml b/android/res/layout/activity_perms_asker.xml
new file mode 100644
index 00000000..d2d12cb6
--- /dev/null
+++ b/android/res/layout/activity_perms_asker.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/res/values/template-dimens.xml b/android/res/values/template-dimens.xml
new file mode 100644
index 00000000..36847c97
--- /dev/null
+++ b/android/res/values/template-dimens.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ 4dp
+ 8dp
+ 16dp
+ 32dp
+ 64dp
+
+
+
+ @dimen/margin_medium
+ @dimen/margin_medium
+
+
\ No newline at end of file
diff --git a/android/src/org/purplei2p/i2pd/I2PDActivity.java b/android/src/org/purplei2p/i2pd/I2PDActivity.java
index 99672eb7..d829bd06 100755
--- a/android/src/org/purplei2p/i2pd/I2PDActivity.java
+++ b/android/src/org/purplei2p/i2pd/I2PDActivity.java
@@ -12,13 +12,14 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
+import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;
-public class I2PDActivity extends Activity {
+public class I2PDActivity extends AppCompatActivity {
private static final String TAG = "i2pdActvt";
public static final int GRACEFUL_DELAY_MILLIS = 10 * 60 * 1000;
diff --git a/android/src/org/purplei2p/i2pd/I2PDPermsAskerActivity.java b/android/src/org/purplei2p/i2pd/I2PDPermsAskerActivity.java
new file mode 100644
index 00000000..5462ab24
--- /dev/null
+++ b/android/src/org/purplei2p/i2pd/I2PDPermsAskerActivity.java
@@ -0,0 +1,121 @@
+package org.purplei2p.i2pd;
+
+import android.Manifest;
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.support.v4.app.ActivityCompat;
+import android.support.design.widget.Snackbar;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+
+//dangerous perms, per https://developer.android.com/guide/topics/permissions/normal-permissions.html :
+//android.permission.WRITE_EXTERNAL_STORAGE
+public class I2PDPermsAskerActivity extends AppCompatActivity {
+
+ private static final int PERMISSION_WRITE_EXTERNAL_STORAGE = 0;
+
+ private View mLayout;
+ private Button button_request_write_ext_storage_perms;
+ private TextView textview_retry;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_perms_asker);
+ mLayout = findViewById(R.id.main_layout);
+ button_request_write_ext_storage_perms = (Button) findViewById(R.id.button_request_write_ext_storage_perms);
+ textview_retry = (TextView) findViewById(R.id.textview_retry);
+
+ button_request_write_ext_storage_perms.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ request_write_ext_storage_perms();
+ }
+ });
+ request_write_ext_storage_perms();
+ }
+
+ private void request_write_ext_storage_perms() {
+
+ textview_retry.setVisibility(TextView.GONE);
+ button_request_write_ext_storage_perms.setVisibility(Button.GONE);
+
+ // Here, thisActivity is the current activity
+ if (ActivityCompat.checkSelfPermission(this,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE)
+ != PackageManager.PERMISSION_GRANTED) {
+
+ // Should we show an explanation?
+ if (ActivityCompat.shouldShowRequestPermissionRationale(this,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
+
+ // Show an explanation to the user *asynchronously* -- don't block
+ // this thread waiting for the user's response! After the user
+ // sees the explanation, try again to request the permission.
+
+ Snackbar.make(mLayout, "SD card write access is required to write the keys and other files to the I2PD folder on SD card.",
+ Snackbar.LENGTH_INDEFINITE).setAction("OK", new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ // Request the permission
+ ActivityCompat.requestPermissions(I2PDPermsAskerActivity.this,
+ new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
+ PERMISSION_WRITE_EXTERNAL_STORAGE);
+ }
+ }).show();
+
+ } else {
+
+ // No explanation needed, we can request the permission.
+
+ ActivityCompat.requestPermissions(this,
+ new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
+ PERMISSION_WRITE_EXTERNAL_STORAGE);
+
+ // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
+ // app-defined int constant. The callback method gets the
+ // result of the request.
+ }
+ } else startMainActivity();
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode,
+ String permissions[], int[] grantResults) {
+ switch (requestCode) {
+ case PERMISSION_WRITE_EXTERNAL_STORAGE: {
+ // If request is cancelled, the result arrays are empty.
+ if (grantResults.length > 0
+ && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+
+ // permission was granted, yay! Do the
+ // contacts-related task you need to do.
+
+ startMainActivity();
+
+ } else {
+
+ // permission denied, boo! Disable the
+ // functionality that depends on this permission.
+ textview_retry.setText("SD card write permission denied, you need to allow this to continue");
+ textview_retry.setVisibility(TextView.VISIBLE);
+ button_request_write_ext_storage_perms.setVisibility(Button.VISIBLE);
+ }
+ return;
+ }
+
+ // other 'case' lines to check for other
+ // permissions this app might request.
+ }
+ }
+
+ private void startMainActivity() {
+ startActivity(new Intent(this, I2PDActivity.class));
+ finish();
+ }
+}