Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class FormMapViewModel(
.getBoolean(ProtectedProjectKeys.KEY_EDIT_SAVED)

return IconifiedText(
if (canEditSaved) R.drawable.ic_edit else R.drawable.ic_visibility,
if (canEditSaved) org.odk.collect.icons.R.drawable.ic_edit else R.drawable.ic_visibility,
resources.getString(if (canEditSaved) org.odk.collect.strings.R.string.edit_data else org.odk.collect.strings.R.string.view_data)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
style="?materialButtonOutlinedIconStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/margin"
android:layout_marginTop="@dimen/margin_standard"
android:text="@string/discard_changes"
app:icon="@drawable/ic_delete"
app:iconGravity="textStart"
Expand Down
2 changes: 1 addition & 1 deletion collect_app/src/main/res/layout/server_auth_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginTop="@dimen/margin"
android:layout_marginTop="@dimen/margin_standard"
android:layout_marginRight="20dip"
android:gravity="fill_horizontal"
android:hint="@string/password"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class FormMapViewModelTest {
smallIcon = R.drawable.ic_room_form_state_incomplete_24dp,
largeIcon = R.drawable.ic_room_form_state_incomplete_48dp,
action = IconifiedText(
R.drawable.ic_edit,
org.odk.collect.icons.R.drawable.ic_edit,
application.getString(org.odk.collect.strings.R.string.edit_data)
),
info = formatDate(
Expand Down Expand Up @@ -153,7 +153,7 @@ class FormMapViewModelTest {
smallIcon = R.drawable.ic_room_form_state_incomplete_24dp,
largeIcon = R.drawable.ic_room_form_state_incomplete_48dp,
action = IconifiedText(
R.drawable.ic_edit,
org.odk.collect.icons.R.drawable.ic_edit,
application.getString(org.odk.collect.strings.R.string.edit_data)
),
info = formatDate(
Expand Down Expand Up @@ -192,7 +192,7 @@ class FormMapViewModelTest {
smallIcon = R.drawable.ic_room_form_state_incomplete_24dp,
largeIcon = R.drawable.ic_room_form_state_incomplete_48dp,
action = IconifiedText(
R.drawable.ic_edit,
org.odk.collect.icons.R.drawable.ic_edit,
application.getString(org.odk.collect.strings.R.string.edit_data)
),
info = formatDate(
Expand Down Expand Up @@ -231,7 +231,7 @@ class FormMapViewModelTest {
smallIcon = R.drawable.ic_room_form_state_incomplete_24dp,
largeIcon = R.drawable.ic_room_form_state_incomplete_48dp,
action = IconifiedText(
R.drawable.ic_edit,
org.odk.collect.icons.R.drawable.ic_edit,
application.getString(org.odk.collect.strings.R.string.edit_data)
),
info = formatDate(
Expand Down
7 changes: 7 additions & 0 deletions draw/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ android {
isIncludeAndroidResources = true
}
}

buildFeatures {
viewBinding = true
}
}

dependencies {
Expand All @@ -57,6 +61,9 @@ dependencies {

debugImplementation(project(":fragments-test"))

testImplementation(project(":androidtest"))
testImplementation(project(":test-shared"))

testImplementation(libs.androidxTestExtJunit)
testImplementation(libs.mockitoKotlin)
testImplementation(libs.androidxTestEspressoCore)
Expand Down
6 changes: 5 additions & 1 deletion draw/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity
android:name=".DrawActivity"
android:theme="@style/Theme.Material3.DayNight"/>
</application>
</manifest>
54 changes: 5 additions & 49 deletions draw/src/main/java/org/odk/collect/draw/DrawActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
Expand All @@ -29,18 +28,14 @@
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import android.view.animation.ScaleAnimation;
import android.widget.AdapterView;
import android.widget.ListView;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.cardview.widget.CardView;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.viewmodel.CreationExtras;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import org.odk.collect.androidshared.bitmap.ImageFileUtils;
Expand All @@ -52,8 +47,6 @@
import org.odk.collect.strings.localization.LocalizedActivity;

import java.io.File;
import java.util.Arrays;
import java.util.List;

import javax.inject.Inject;

Expand Down Expand Up @@ -82,8 +75,6 @@ public class DrawActivity extends LocalizedActivity {
private File savepointImage;

private DrawView drawView;
private String alertTitleString;
private AlertDialog alertDialog;

private DrawViewModel drawViewModel;

Expand Down Expand Up @@ -210,17 +201,6 @@ public void onClick(View view) {
// original)
// output -- where the output should be written

if (OPTION_SIGNATURE.equals(loadOption)) {
alertTitleString = getString(org.odk.collect.strings.R.string.quit_application,
getString(org.odk.collect.strings.R.string.sign_button));
} else if (OPTION_ANNOTATE.equals(loadOption)) {
alertTitleString = getString(org.odk.collect.strings.R.string.quit_application,
getString(org.odk.collect.strings.R.string.markup_image));
} else {
alertTitleString = getString(org.odk.collect.strings.R.string.quit_application,
getString(org.odk.collect.strings.R.string.draw_image));
}

drawView.setupView(OPTION_SIGNATURE.equals(loadOption));

viewModel.getPenColor().observe(this, penColor -> {
Expand Down Expand Up @@ -286,35 +266,11 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
* saving
*/
private void createQuitDrawDialog() {
int dividerHeight = getResources().getDimensionPixelSize(org.odk.collect.androidshared.R.dimen.margin_extra_small);
ListView actionListView = new ListView(this);
actionListView.setPadding(0, dividerHeight, 0, 0);
actionListView.setDivider(new ColorDrawable(Color.TRANSPARENT));
actionListView.setDividerHeight(dividerHeight);

List<IconMenuListAdapter.IconMenuItem> items;
items = Arrays.asList(new IconMenuListAdapter.IconMenuItem(org.odk.collect.icons.R.drawable.ic_save, org.odk.collect.strings.R.string.keep_changes),
new IconMenuListAdapter.IconMenuItem(org.odk.collect.icons.R.drawable.ic_delete, org.odk.collect.strings.R.string.discard_changes));

final IconMenuListAdapter adapter = new IconMenuListAdapter(this, items);
actionListView.setAdapter(adapter);
actionListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
IconMenuListAdapter.IconMenuItem item = (IconMenuListAdapter.IconMenuItem) adapter.getItem(position);
if (item.getTextResId() == org.odk.collect.strings.R.string.keep_changes) {
drawViewModel.save(drawView);
} else {
cancelAndClose();
}
alertDialog.dismiss();
}
});
alertDialog = new MaterialAlertDialogBuilder(this)
.setTitle(alertTitleString)
.setPositiveButton(getString(org.odk.collect.strings.R.string.do_not_exit), null)
.setView(actionListView).create();
alertDialog.show();
QuitDrawingDialog.show(
this,
this::cancelAndClose,
() -> drawViewModel.save(drawView)
);
}

private void clear(View view) {
Expand Down
98 changes: 0 additions & 98 deletions draw/src/main/java/org/odk/collect/draw/IconMenuListAdapter.java

This file was deleted.

50 changes: 50 additions & 0 deletions draw/src/main/java/org/odk/collect/draw/QuitDrawingDialog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.odk.collect.draw

import android.app.Activity
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.odk.collect.draw.databinding.QuitDrawingDialogLayoutBinding

object QuitDrawingDialog {

@JvmStatic
fun show(
activity: Activity,
onDiscardChanges: Runnable?,
onSaveChanges: Runnable?
): AlertDialog {
return create(
activity,
onDiscardChanges,
onSaveChanges
).also {
it.show()
}
}

private fun create(
activity: Activity,
onDiscardChanges: Runnable?,
onSaveChanges: Runnable?
): AlertDialog {
val binding = QuitDrawingDialogLayoutBinding.inflate(activity.layoutInflater)
val dialog = MaterialAlertDialogBuilder(activity)
.setTitle(org.odk.collect.strings.R.string.save_drawing_title)
.setView(binding.root)
.create()

binding.discardChanges.setOnClickListener {
onDiscardChanges?.run()
}

binding.keepEditing.setOnClickListener {
dialog.dismiss()
}

binding.saveChanges.setOnClickListener {
onSaveChanges?.run()
}

return dialog
}
}
16 changes: 16 additions & 0 deletions draw/src/main/java/org/odk/collect/draw/RobolectricApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.odk.collect.draw

import android.app.Application
/**
* Used as the Application in tests in in the `test/src` root. This is setup in `robolectric.properties`
*/
internal class RobolectricApplication : Application(), DrawDependencyComponentProvider {

override lateinit var drawDependencyComponent: DrawDependencyComponent

fun setupDependencies(dependencyModule: DrawDependencyModule) {
drawDependencyComponent = DaggerDrawDependencyComponent.builder()
.drawDependencyModule(dependencyModule)
.build()
}
}
16 changes: 0 additions & 16 deletions draw/src/main/res/layout/item_view_option.xml

This file was deleted.

Loading