5 Commits

11 changed files with 102 additions and 75 deletions

View File

@ -11,7 +11,7 @@ android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
useLibrary 'org.apache.http.legacy'
versionCode 97
versionCode 98
versionName "1.6.22"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -49,7 +49,7 @@ android {
{
dimension "version"
// applicationIdSuffix ".fdroid"
versionNameSuffix "-fdroid"
// versionNameSuffix "-fdroid"
targetSdkVersion 28
}

View File

@ -10,7 +10,7 @@
{
"type": "SINGLE",
"filters": [],
"versionCode": 97,
"versionCode": 98,
"versionName": "1.6.22-googlePlay",
"outputFile": "app-googlePlayFlavor-release.apk"
}

View File

@ -53,11 +53,11 @@ public class ActivityMainPoi extends ActivityGeneric
@Override
public void onClick(View v)
{
if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainPoi.this))
{
Toast.makeText(ActivityMainPoi.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
return;
}
// if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainPoi.this))
// {
// Toast.makeText(ActivityMainPoi.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
// return;
// }
if(!ActivityPermissions.havePermission(ActivityPermissions.permissionNameLocationCoarse, ActivityMainPoi.this) || !ActivityPermissions.havePermission(ActivityPermissions.permissionNameLocationFine, ActivityMainPoi.this))
{

View File

@ -50,11 +50,11 @@ public class ActivityMainProfiles extends ActivityGeneric
@Override
public void onClick(View v)
{
if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainProfiles.this))
{
Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
return;
}
// if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainProfiles.this))
// {
// Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
// return;
// }
profileToEdit = null;
Intent manageSpecificProfileIntent = new Intent (ActivityMainProfiles.this, ActivityManageProfile.class);

View File

@ -52,11 +52,11 @@ public class ActivityMainRules extends ActivityGeneric
@Override
public void onClick(View v)
{
if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainRules.this))
{
Toast.makeText(ActivityMainRules.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
return;
}
// if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, ActivityMainRules.this))
// {
// Toast.makeText(ActivityMainRules.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
// return;
// }
ruleToEdit = null;
Intent startAddRuleIntent = new Intent(ActivityMainRules.this, ActivityManageRule.class);

View File

@ -281,8 +281,8 @@ public class ActivityPermissions extends Activity
addToArrayListUnique("android.permission.RECEIVE_BOOT_COMPLETED", requiredPermissions);
*/
if (!havePermission("android.permission.WRITE_EXTERNAL_STORAGE", workingContext))
addToArrayListUnique("android.permission.WRITE_EXTERNAL_STORAGE", requiredPermissions);
// if (!havePermission(ActivityPermissions.writeExternalStoragePermissionName, workingContext))
// addToArrayListUnique(ActivityPermissions.writeExternalStoragePermissionName, requiredPermissions);
for(Profile profile : Profile.getProfileCollection())
{

View File

@ -106,17 +106,17 @@ public class AutomationService extends Service implements OnInitListener
public boolean checkStartupRequirements(Context context, boolean startAtBoot)
{
if (!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, AutomationService.this))
{
/*
Don't have permission to access external storage. This is a show stopper as
the configuration file is stored on external storage.
*/
Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
// Toast.makeText(AutomationService.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
return false;
}
// if (!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, AutomationService.this))
// {
// /*
// Don't have permission to access external storage. This is a show stopper as
// the configuration file is stored on external storage.
// */
// Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
//// Toast.makeText(AutomationService.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
// ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
// return false;
// }
if(Build.VERSION.SDK_INT >= 28)
{

View File

@ -313,6 +313,18 @@ public class Miscellaneous extends Service
{
if(writeableFolderStringCache == null)
{
// Use the app-specific folder as new default.
writeableFolderStringCache = Miscellaneous.getAnyContext().getFilesDir().getAbsolutePath();
File newConfigFile = new File(writeableFolderStringCache + "/" + XmlFileInterface.settingsFileName);
migration:
if (!newConfigFile.exists())
{
if (ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, Miscellaneous.getAnyContext()))
{
// We have the storage permission, probably because it's an old installation. Files should be migrated to app-specific folder.
String testPath = null;
File folder = null;
@ -326,31 +338,38 @@ public class Miscellaneous extends Service
"/mnt/sdcard"
};
for(String f : foldersToTestArray)
for (String f : foldersToTestArray)
{
if (testFolder(f))
{
String pathToUse = f + "/" + Settings.folderName;
Miscellaneous.logEvent("i", "Path", "Using " + pathToUse + " to store settings and log.", 2);
// Toast.makeText(getAnyContext(), "Using " + pathToUse + " to store settings and log.", Toast.LENGTH_LONG).show();
return pathToUse;
}
else
Miscellaneous.logEvent("e", "getWritableFolder", folder.getAbsolutePath() + " does not exist and could not be created.", 3);
// Migrate existing files
File oldDirectory = new File(pathToUse);
File newDirectory = new File(writeableFolderStringCache);
File oldConfigFilePath = new File(pathToUse + "/" + XmlFileInterface.settingsFileName);
if (oldConfigFilePath.exists() && oldConfigFilePath.canWrite())
{
Miscellaneous.logEvent("i", "Path", "Found old path " + pathToUse + " for settings and logs. Migrating old files to new directory.", 2);
for (File moveFile : oldDirectory.listFiles())
moveFile.renameTo(newDirectory);
String message = String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.filesHaveBeenMovedTo), newDirectory.getAbsolutePath());
Miscellaneous.writeStringToFile(oldDirectory.getAbsolutePath() + "readme.txt", message);
break migration;
}
}
catch(Exception e)
}
} catch (Exception e)
{
Log.w("getWritableFolder", folder + " not writable.");
}
// do not change to logEvent() - we can't write
Toast.makeText(getAnyContext(), "No writable folder could be found.", Toast.LENGTH_LONG).show();
Log.e("getWritableFolder", "No writable folder could be found.");
return null;
}
else
}
}
return writeableFolderStringCache;
}

View File

@ -107,7 +107,7 @@ public class Settings implements SharedPreferences
protected static final boolean default_privacyLocationing = false;
protected static final int default_startScreen = 0;
protected static final boolean default_executeRulesAndProfilesWithSingleClick = false;
protected static final boolean default_displayNewsOnMainScreen = true;
protected static final boolean default_displayNewsOnMainScreen = false;
protected static final boolean default_lockSoundChanges = false;
protected static final long default_lastNewsPolltime = -1;

View File

@ -25,7 +25,8 @@ import java.util.Collections;
public class XmlFileInterface
{
public static File settingsFile = new File(Miscellaneous.getWriteableFolder() + "/Automation_settings.xml");
public static String settingsFileName = "Automation_settings.xml";
public static File settingsFile = new File(Miscellaneous.getWriteableFolder() + "/" + settingsFileName);
public static Context context;
protected static final String encryptionKey = "Y1vsP12L2S3NkTJbDOR4bQ6i02hsoo";
@ -343,18 +344,23 @@ public class XmlFileInterface
}
public static void readFile() throws FileNotFoundException
{
if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, Miscellaneous.getAnyContext()))
{
/*
Don't have permission to access external storage. This is a show stopper as
the configuration file is stored on external storage.
Storage location has been moved to app-specific folder in Android/data
Hence this permission is not requested any more. If it is already granted we assume the files are on /sdcard or similar.
Migration to app-specific folder has yet to be implemented.
*/
Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
Toast.makeText(Miscellaneous.getAnyContext(), Miscellaneous.getAnyContext().getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
return;
}
// if(!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, Miscellaneous.getAnyContext()))
// {
// /*
// Don't have permission to access external storage. This is a show stopper as
// the configuration file is stored on external storage.
// */
// Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
// Toast.makeText(Miscellaneous.getAnyContext(), Miscellaneous.getAnyContext().getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
// ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
// return;
// }
/*
If we are here it may be that we just got permission to read storage. We need to check for the

View File

@ -594,7 +594,8 @@
<string name="startScreen">Start screen</string>
<string name="startScreenSummary">Select the screen the applications opens withs at start.</string>
<string name="executeRulesAndProfilesWithSingleClickTitle">Run rules/profiles with single click.</string>
<string name="googleLocationChicanery">This app collects location data to determine if you\'re currently at one of the locations you created. Furthermore it is used to determine your current speed if you are using that trigger in rules. That is done even when the app is closed or not in use (but only when the service is activated).</string>
<string name="googleLocationChicanery">This app collects location data to enable location based rules and speed detection even when the app is closed or not in use.</string>
<string name="googleLocationChicaneryOld">This app collects location data to determine if you\'re currently at one of the locations you created. Furthermore it is used to determine your current speed if you are using that trigger in rules. That is done even when the app is closed or not in use (but only when the service is activated).</string>
<string name="android.permission.ACCESS_BACKGROUND_LOCATION">Read location in background.</string>
<string name="deviceDoesNotHaveBluetooth">This device does not seem to have bluetooth. You can still continue configuring this, but it will most likely not have an effect.</string>
<string name="manageLocations">Create or edit locations</string>
@ -604,4 +605,5 @@
<string name="publishedOn">published on</string>
<string name="displayNewsOnMainScreen">Display application news on main screen</string>
<string name="displayNewsOnMainScreenDescription">Announcements about this app only, we\'re probably talking about 1-2 per year, not more.</string>
<string name="filesHaveBeenMovedTo">Automation now uses another path to store your files. The existing ones have been moved. You can find them here: %s.</string>
</resources>