Skip to content

Commit

Permalink
Merge branch 'master' into translations_47097d25622d49a791179be740f7b…
Browse files Browse the repository at this point in the history
…8be_ru
  • Loading branch information
andreynovikov committed Feb 15, 2024
2 parents 6e2619e + 6425862 commit d208faa
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 124 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout source code
uses: actions/checkout@v3
#- name: Update gradle.properties
# run: |
# echo RELEASE_STORE_FILE=release.keystore >> ./gradle.properties
# echo RELEASE_STORE_PASSWORD=${{ secrets.RELEASE_STORE_PASSWORD }} >> ./gradle.properties
# echo RELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }} >> ./gradle.properties
# echo RELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }} >> ./gradle.properties
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand All @@ -32,7 +39,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout source code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
16 changes: 12 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ android {
}

signingConfigs {
debug {
storeFile file("debug.keystore")
storePassword "android"
keyAlias "AndroidDebugKey"
keyPassword "android"
}
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
storeFile file(project.hasProperty('RELEASE_STORE_FILE') ? RELEASE_STORE_FILE : "debug.keystore")
storePassword project.hasProperty('RELEASE_STORE_PASSWORD') ? RELEASE_STORE_PASSWORD : "android"
keyAlias project.hasProperty('RELEASE_KEY_ALIAS') ? RELEASE_KEY_ALIAS : "AndroidDebugKey"
keyPassword project.hasProperty('RELEASE_KEY_PASSWORD') ? RELEASE_KEY_PASSWORD : "android"
}
}

Expand Down Expand Up @@ -76,7 +82,9 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.5.1'
androidTestImplementation 'androidx.test:rules:1.5.0'
implementation "androidx.tracing:tracing:1.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.7.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.7.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.7.0"
Expand Down
Binary file added app/debug.keystore
Binary file not shown.
100 changes: 54 additions & 46 deletions app/src/androidTest/java/mobi/maptrek/SimpleRunTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.action.ViewActions.longClick;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
import static androidx.test.espresso.matcher.RootMatchers.isDialog;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
Expand Down Expand Up @@ -72,8 +73,9 @@ public void beforeTest() {

@Test
public void mainActivityTest() {
// Close Introduction panel if test is running separately

try {
// Close Introduction panel if test is running separately
ViewInteraction appCompatButton = onView(
allOf(
withId(R.id.skip),
Expand All @@ -87,6 +89,7 @@ public void mainActivityTest() {
}

// World map download dialog is displayed - close it

ViewInteraction appCompatButton2 = onView(
allOf(
withId(android.R.id.button2),
Expand All @@ -102,53 +105,76 @@ public void mainActivityTest() {
allOf(
withId(R.id.moreButton),
childAtPosition(
allOf(
withId(R.id.actionPanel),
childAtPosition(
withClassName(is("android.widget.RelativeLayout")),
1
)
),
withId(R.id.actionPanel),
4
),
isDisplayed()
)
);
appCompatImageButton.perform(click());

// Press 'About' menu item
// Press 'Settings' menu item

DataInteraction linearLayout = onData(anything())
.inAdapterView(
allOf(
withId(android.R.id.list),
childAtPosition(
withClassName(is("android.widget.FrameLayout")),
0
withClassName(is("android.widget.FrameLayout")),
0
)
)
)
.atPosition(0);
.atPosition(1);
linearLayout.perform(click());

// Check for 'Trekarta' title
// Check for 'About' preference item

ViewInteraction textView = onView(
allOf(
withId(android.R.id.title),
withText("About"),
isDisplayed()
)
);
textView.check(matches(withText("About")));

// Press 'About' preference item

ViewInteraction recyclerView = onView(
allOf(
withId(androidx.preference.R.id.recycler_view),
childAtPosition(
withId(android.R.id.list_container),
0
)
)
);
recyclerView.perform(actionOnItemAtPosition(3, click()));

// Check for 'Trekarta' title

ViewInteraction imageView = onView(
allOf(
withId(R.id.title),
withContentDescription("Trekarta"),
childAtPosition(
childAtPosition(
IsInstanceOf.instanceOf(android.widget.LinearLayout.class),
0
),
1
),
isDisplayed()
)
);
textView.check(matches(withContentDescription("Trekarta")));
imageView.check(matches(isDisplayed()));

// Check for 'trekarta.info' link

ViewInteraction textView2 = onView(
allOf(
withId(R.id.links),
withText("https://trekarta.info/"),
isDisplayed()
)
);
textView2.check(matches(withText("https://trekarta.info/")));

pressBack();
pressBack();

// Press 'Places' button
Expand All @@ -157,13 +183,7 @@ public void mainActivityTest() {
allOf(
withId(R.id.placesButton),
childAtPosition(
allOf(
withId(R.id.actionPanel),
childAtPosition(
withClassName(is("android.widget.RelativeLayout")),
1
)
),
withId(R.id.actionPanel),
2
),
isDisplayed()
Expand All @@ -179,13 +199,7 @@ public void mainActivityTest() {
allOf(
withId(R.id.mapsButton),
childAtPosition(
allOf(
withId(R.id.actionPanel),
childAtPosition(
withClassName(is("android.widget.RelativeLayout")),
1
)
),
withId(R.id.actionPanel),
3
),
isDisplayed()
Expand All @@ -200,8 +214,8 @@ public void mainActivityTest() {
allOf(
withId(android.R.id.list),
childAtPosition(
withClassName(is("android.widget.FrameLayout")),
0
withClassName(is("android.widget.FrameLayout")),
0
)
)
)
Expand All @@ -210,7 +224,7 @@ public void mainActivityTest() {

// Find first legend title

ViewInteraction textView2 = onView(
ViewInteraction textView3 = onView(
allOf(
withId(R.id.name),
withText("Administrative"),
Expand All @@ -224,7 +238,7 @@ public void mainActivityTest() {
isDisplayed()
)
);
textView2.check(matches(withText("Administrative")));
textView3.check(matches(withText("Administrative")));

pressBack();

Expand All @@ -234,13 +248,7 @@ public void mainActivityTest() {
allOf(
withId(R.id.locationButton),
childAtPosition(
allOf(
withId(R.id.actionPanel),
childAtPosition(
withClassName(is("android.widget.RelativeLayout")),
1
)
),
withId(R.id.actionPanel),
0
),
isDisplayed()
Expand Down
18 changes: 10 additions & 8 deletions app/src/main/java/mobi/maptrek/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4273,7 +4273,7 @@ private void removeWaypointMarker(Waypoint waypoint) {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
if (mMap.getEventLayer().moveEnabled()) {
if (mObjectInteractionEnabled && mMap.getEventLayer().moveEnabled()) {
AbstractMapEventLayer eventLayer = mMap.getEventLayer();
eventLayer.enableMove(false);
eventLayer.enableRotation(false);
Expand All @@ -4299,13 +4299,15 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
AbstractMapEventLayer eventLayer = mMap.getEventLayer();
eventLayer.enableMove(true);
eventLayer.enableRotation(true);
eventLayer.enableTilt(true);
eventLayer.enableZoom(true);
mCrosshairLayer.unlock();
mPositionLocked = false;
if (mObjectInteractionEnabled) {
AbstractMapEventLayer eventLayer = mMap.getEventLayer();
eventLayer.enableMove(true);
eventLayer.enableRotation(true);
eventLayer.enableTilt(true);
eventLayer.enableZoom(true);
mCrosshairLayer.unlock();
mPositionLocked = false;
}
return true;
}
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/mobi/maptrek/fragments/DataSourceList.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.MimeTypeMap;
import android.widget.PopupMenu;

Expand All @@ -41,7 +43,6 @@
import androidx.recyclerview.widget.ListAdapter;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textview.MaterialTextView;

import org.slf4j.Logger;
Expand Down Expand Up @@ -303,6 +304,8 @@ class DataSourceViewHolder extends BindableViewHolder {

@Override
void bindView(DataSource dataSource, int position) {
Context context = getContext();

name.setText(dataSource.name);

@ColorInt int color = accentColor;
Expand Down Expand Up @@ -365,7 +368,7 @@ else if (routesCount > 0 && waypointsCount == 0 && tracksCount == 0)
}
itemView.setOnClickListener(v -> dataSourceViewModel.selectDataSource(dataSource, DataSourceViewModel.MODE_SELECTOR));
} else {
String size = Formatter.formatShortFileSize(getContext(), file.length());
String size = Formatter.formatShortFileSize(context, file.length());
if (nativeTracksMode) {
description.setText(String.format(Locale.ENGLISH, "%s", size));
icon.setImageResource(R.drawable.ic_track);
Expand All @@ -378,13 +381,10 @@ else if (routesCount > 0 && waypointsCount == 0 && tracksCount == 0)
icon.setImageResource(R.drawable.ic_dataset);
}
color = disabledColor;
itemView.setOnClickListener(v -> Snackbar.make(viewBinding.getRoot(), R.string.msgDataSourceNotLoaded, Snackbar.LENGTH_SHORT)
.setAction(R.string.actionEnable, view -> {
mDataHolder.setDataSourceAvailability((FileDataSource) dataSource, true);
notifyItemChanged(position);
})
.setAnchorView(v)
.show());
itemView.setOnClickListener(v -> {
Animation shake = AnimationUtils.loadAnimation(context, R.anim.shake);
action.startAnimation(shake);
});
}
final boolean shown = dataSource.isVisible();
if (shown)
Expand All @@ -399,7 +399,7 @@ else if (routesCount > 0 && waypointsCount == 0 && tracksCount == 0)
}
icon.setImageTintList(ColorStateList.valueOf(color));
itemView.setOnLongClickListener(v -> {
PopupMenu popup = new PopupMenu(getContext(), v);
PopupMenu popup = new PopupMenu(context, v);
popup.inflate(R.menu.context_menu_data_list);
if (dataSource instanceof WaypointDbDataSource)
popup.getMenu().findItem(R.id.action_delete).setVisible(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
ImageButton inputButton = mRootView.findViewById(R.id.inputButton);
inputButton.setOnClickListener(v -> {
TextInputDialogFragment.Builder builder = new TextInputDialogFragment.Builder();
mTextInputDialog = builder.setCallbacks(LocationInformation.this)
mTextInputDialog = builder.setCallback(LocationInformation.this)
.setHint(container.getContext().getString(R.string.coordinates))
.setShowPasteButton(true)
.create();
Expand Down
Loading

0 comments on commit d208faa

Please sign in to comment.