kopia lustrzana https://github.com/ge0rg/aprsdroid
				
				
				
			Merge 214b77d73f into 859033e0d7
				
					
				
			
						commit
						74e63a6177
					
				| 
						 | 
					@ -1,15 +1,15 @@
 | 
				
			||||||
package org.aprsdroid.app;
 | 
					package org.aprsdroid.app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static org.junit.Assert.assertEquals;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import android.content.Context;
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import android.support.test.InstrumentationRegistry;
 | 
					import androidx.test.ext.junit.runners.AndroidJUnit4;
 | 
				
			||||||
import android.support.test.runner.AndroidJUnit4;
 | 
					import androidx.test.platform.app.InstrumentationRegistry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.junit.Test;
 | 
					import org.junit.Test;
 | 
				
			||||||
import org.junit.runner.RunWith;
 | 
					import org.junit.runner.RunWith;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static org.junit.Assert.*;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Instrumented test, which will execute on an Android device.
 | 
					 * Instrumented test, which will execute on an Android device.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,55 @@
 | 
				
			||||||
 | 
					package org.aprsdroid.app;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static androidx.test.espresso.Espresso.onView;
 | 
				
			||||||
 | 
					import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
 | 
				
			||||||
 | 
					import static androidx.test.espresso.action.ViewActions.click;
 | 
				
			||||||
 | 
					import static androidx.test.espresso.intent.matcher.IntentMatchers.hasAction;
 | 
				
			||||||
 | 
					import static androidx.test.espresso.matcher.ViewMatchers.withText;
 | 
				
			||||||
 | 
					import static org.hamcrest.Matchers.allOf;
 | 
				
			||||||
 | 
					import static org.junit.Assume.assumeTrue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.Manifest;
 | 
				
			||||||
 | 
					import android.app.Instrumentation;
 | 
				
			||||||
 | 
					import android.content.Intent;
 | 
				
			||||||
 | 
					import android.os.Environment;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.test.core.app.ActivityScenario;
 | 
				
			||||||
 | 
					import androidx.test.espresso.intent.Intents;
 | 
				
			||||||
 | 
					import androidx.test.ext.junit.runners.AndroidJUnit4;
 | 
				
			||||||
 | 
					import androidx.test.platform.app.InstrumentationRegistry;
 | 
				
			||||||
 | 
					import androidx.test.rule.GrantPermissionRule;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.junit.After;
 | 
				
			||||||
 | 
					import org.junit.Before;
 | 
				
			||||||
 | 
					import org.junit.Rule;
 | 
				
			||||||
 | 
					import org.junit.Test;
 | 
				
			||||||
 | 
					import org.junit.runner.RunWith;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@RunWith(AndroidJUnit4.class)
 | 
				
			||||||
 | 
					public class ProfileTests {
 | 
				
			||||||
 | 
					    @Rule
 | 
				
			||||||
 | 
					    public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Before
 | 
				
			||||||
 | 
					    public void setUp() {
 | 
				
			||||||
 | 
					        Intents.init();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @After
 | 
				
			||||||
 | 
					    public void tearDown() {
 | 
				
			||||||
 | 
					        Intents.release();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Test
 | 
				
			||||||
 | 
					    public void testThatExportProfileOpensTheChooser() {
 | 
				
			||||||
 | 
					        assumeTrue(Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()));
 | 
				
			||||||
 | 
					        ActivityScenario scenario = ActivityScenario.launch(PrefsAct.class);
 | 
				
			||||||
 | 
					        Intents.intending(hasAction(Intent.ACTION_CHOOSER)).respondWith(new Instrumentation.ActivityResult(0, null));
 | 
				
			||||||
 | 
					        openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getInstrumentation().getTargetContext());
 | 
				
			||||||
 | 
					        onView(withText(R.string.profile_export))
 | 
				
			||||||
 | 
					                .perform(click());
 | 
				
			||||||
 | 
					        Intents.intended(hasAction(Intent.ACTION_MAIN));  // Validate the activity launch
 | 
				
			||||||
 | 
					        Intents.intended(allOf(hasAction(Intent.ACTION_CHOOSER)));
 | 
				
			||||||
 | 
					        Intents.assertNoUnverifiedIntents();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										16
									
								
								build.gradle
								
								
								
								
							
							
						
						
									
										16
									
								
								build.gradle
								
								
								
								
							| 
						 | 
					@ -6,7 +6,7 @@ buildscript {
 | 
				
			||||||
		google()
 | 
							google()
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	dependencies {
 | 
						dependencies {
 | 
				
			||||||
		classpath 'com.android.tools.build:gradle:3.5.1'
 | 
							classpath 'com.android.tools.build:gradle:3.5.4'
 | 
				
			||||||
		// NOTE: Do not place your application dependencies here; they belong
 | 
							// NOTE: Do not place your application dependencies here; they belong
 | 
				
			||||||
		// in the individual module build.gradle files
 | 
							// in the individual module build.gradle files
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,7 +81,7 @@ android {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		resValue "string", "google_maps_key", mapsApiKey()
 | 
							resValue "string", "google_maps_key", mapsApiKey()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
 | 
							testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	useLibrary 'org.apache.http.legacy'
 | 
						useLibrary 'org.apache.http.legacy'
 | 
				
			||||||
	compileOptions {
 | 
						compileOptions {
 | 
				
			||||||
| 
						 | 
					@ -158,7 +158,13 @@ dependencies {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	implementation 'com.squareup.okio:okio:2.1.0'
 | 
						implementation 'com.squareup.okio:okio:2.1.0'
 | 
				
			||||||
	androidTestImplementation 'com.android.support.test:runner:1.0.2'
 | 
					
 | 
				
			||||||
	androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
 | 
						testImplementation 'junit:junit:4.13.1'
 | 
				
			||||||
	testImplementation 'junit:junit:4.12'
 | 
						testImplementation 'org.hamcrest:hamcrest-core:1.3'
 | 
				
			||||||
 | 
						testImplementation 'org.hamcrest:hamcrest-library:1.3'
 | 
				
			||||||
 | 
						androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
 | 
				
			||||||
 | 
						androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
 | 
				
			||||||
 | 
						androidTestImplementation 'androidx.test:runner:1.4.0'
 | 
				
			||||||
 | 
						androidTestImplementation 'androidx.test:rules:1.4.0'
 | 
				
			||||||
 | 
						androidTestImplementation 'androidx.test.ext:junit:1.1.3'
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
 | 
					<paths xmlns:android="http://schemas.android.com/apk/res/android">
 | 
				
			||||||
   <external-path name="APRSdroid" path="Documents/APRSdroid" />
 | 
					   <external-path name="APRSdroid" path="Documents/APRSdroid" />
 | 
				
			||||||
 | 
					   <external-path name="APRSdroid-top" path="APRSdroid" />
 | 
				
			||||||
</paths>
 | 
					</paths>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,8 @@ import _root_.android.preference.PreferenceActivity
 | 
				
			||||||
import _root_.android.preference.PreferenceManager
 | 
					import _root_.android.preference.PreferenceManager
 | 
				
			||||||
import _root_.android.view.{Menu, MenuItem}
 | 
					import _root_.android.view.{Menu, MenuItem}
 | 
				
			||||||
import _root_.android.widget.Toast
 | 
					import _root_.android.widget.Toast
 | 
				
			||||||
 | 
					import android.util.Log
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.text.SimpleDateFormat
 | 
					import java.text.SimpleDateFormat
 | 
				
			||||||
import java.io.{File, PrintWriter}
 | 
					import java.io.{File, PrintWriter}
 | 
				
			||||||
import java.util.Date
 | 
					import java.util.Date
 | 
				
			||||||
| 
						 | 
					@ -16,6 +18,8 @@ import java.util.Date
 | 
				
			||||||
import org.json.JSONObject
 | 
					import org.json.JSONObject
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class PrefsAct extends PreferenceActivity {
 | 
					class PrefsAct extends PreferenceActivity {
 | 
				
			||||||
 | 
						val TAG = "APRSdroid.PrefsAct"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	lazy val db = StorageDatabase.open(this)
 | 
						lazy val db = StorageDatabase.open(this)
 | 
				
			||||||
	lazy val prefs = new PrefsWrapper(this)
 | 
						lazy val prefs = new PrefsWrapper(this)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,7 +37,10 @@ class PrefsAct extends PreferenceActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			UIHelper.shareFile(this, file, filename)
 | 
								UIHelper.shareFile(this, file, filename)
 | 
				
			||||||
		} catch {
 | 
							} catch {
 | 
				
			||||||
			case e : Exception => Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show()
 | 
								case e : Exception => {
 | 
				
			||||||
 | 
									Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show()
 | 
				
			||||||
 | 
									Log.i(TAG, "Caught exception sharing file: " + e, e)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,7 +69,7 @@ class PrefsAct extends PreferenceActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def resolveContentUri(uri : Uri) = {
 | 
						def resolveContentUri(uri : Uri) = {
 | 
				
			||||||
		val Array(storage, path) = uri.getPath().replace("/document/", "").split(":", 2)
 | 
							val Array(storage, path) = uri.getPath().replace("/document/", "").split(":", 2)
 | 
				
			||||||
		android.util.Log.d("PrefsAct", "resolveContentUri s=" + storage + " p=" + path)
 | 
							android.util.Log.d(TAG, "resolveContentUri s=" + storage + " p=" + path)
 | 
				
			||||||
		if (storage == "primary")
 | 
							if (storage == "primary")
 | 
				
			||||||
			Environment.getExternalStorageDirectory() + "/" + path
 | 
								Environment.getExternalStorageDirectory() + "/" + path
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
| 
						 | 
					@ -108,7 +115,7 @@ class PrefsAct extends PreferenceActivity {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	override def onActivityResult(reqCode : Int, resultCode : Int, data : Intent) {
 | 
						override def onActivityResult(reqCode : Int, resultCode : Int, data : Intent) {
 | 
				
			||||||
		android.util.Log.d("PrefsAct", "onActResult: request=" + reqCode + " result=" + resultCode + " " + data)
 | 
							android.util.Log.d(TAG, "onActResult: request=" + reqCode + " result=" + resultCode + " " + data)
 | 
				
			||||||
		if (resultCode == android.app.Activity.RESULT_OK && reqCode == 123456) {
 | 
							if (resultCode == android.app.Activity.RESULT_OK && reqCode == 123456) {
 | 
				
			||||||
			//parseFilePickerResult(data, "mapfile", R.string.mapfile_error)
 | 
								//parseFilePickerResult(data, "mapfile", R.string.mapfile_error)
 | 
				
			||||||
			val takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
 | 
								val takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Ładowanie…
	
		Reference in New Issue