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.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -167,6 +165,9 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
private DrawerLayout drawerLayout;
private boolean drawerDisabled;
private boolean permissionAsked;
private boolean permissionGranted;
private Notification getNotification() {
Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity());
notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@ -590,6 +591,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
System.err.println("OnCreate for MapActivity took " + (System.currentTimeMillis() - tm) + " ms");
}
if (!permissionAsked) {
if (app.isExternalStorageDirectoryReadOnly()
&& getSupportFragmentManager().findFragmentByTag(DataStoragePlaceDialogFragment.TAG) == null) {
if (DownloadActivity.hasPermissionToWriteExternalStorage(this)) {
@ -600,6 +602,15 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
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;
}
}
private void restartApp() {
@ -1222,24 +1233,8 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
&& grantResults.length > 0 && permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
new Timer().schedule(new TimerTask() {
@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);
}
permissionAsked = true;
permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);