Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-03-10 10:15:50 +01:00
commit 33c5ace0bf

View file

@ -110,8 +110,6 @@ import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -167,6 +165,9 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
private boolean drawerDisabled; private boolean drawerDisabled;
private boolean permissionAsked;
private boolean permissionGranted;
private Notification getNotification() { private Notification getNotification() {
Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity()); Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity());
notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@ -590,15 +591,25 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms"); System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
} }
if (app.isExternalStorageDirectoryReadOnly() if (!permissionAsked) {
&& getSupportFragmentManager().findFragmentByTag(DataStoragePlaceDialogFragment.TAG) == null) { if (app.isExternalStorageDirectoryReadOnly()
if (DownloadActivity.hasPermissionToWriteExternalStorage(this)) { && getSupportFragmentManager().findFragmentByTag(DataStoragePlaceDialogFragment.TAG) == null) {
DataStoragePlaceDialogFragment.showInstance(getSupportFragmentManager(), true); if (DownloadActivity.hasPermissionToWriteExternalStorage(this)) {
} else { DataStoragePlaceDialogFragment.showInstance(getSupportFragmentManager(), true);
ActivityCompat.requestPermissions(this, } else {
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, ActivityCompat.requestPermissions(this,
DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
}
} }
} else {
if (permissionGranted) {
restartApp();
} else if (getSupportFragmentManager().findFragmentByTag(DataStoragePlaceDialogFragment.TAG) == null) {
DataStoragePlaceDialogFragment.showInstance(getSupportFragmentManager(), true);
}
permissionAsked = false;
permissionGranted = false;
} }
} }
@ -1222,24 +1233,8 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
&& grantResults.length > 0 && permissions.length > 0 && grantResults.length > 0 && permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) { && Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { permissionAsked = true;
new Timer().schedule(new TimerTask() { permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
@Override
public void run() {
restartApp();
}
}, 1);
} else {
AccessibleToast.makeText(this,
R.string.missing_write_external_storage_permission,
Toast.LENGTH_LONG).show();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
DataStoragePlaceDialogFragment.showInstance(getSupportFragmentManager(), true);
}
}, 1);
}
} }
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);