Add actions to buttons; change description

This commit is contained in:
alex 2017-10-27 14:45:55 +03:00
parent 98424b997b
commit f3ec5730d6
3 changed files with 60 additions and 29 deletions

View file

@ -33,17 +33,33 @@
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<TextView
android:id="@+id/import_gpx_description"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_descr_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="You can import Berlin_CultourTour.gpx as Favorites points, or as track file."/>
android:paddingStart="@dimen/content_padding">
<TextView
android:id="@+id/import_gpx_file_name_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
tools:text="Berlin_CultourTour.gpx"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/import_gpx_file_description"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
<LinearLayout
android:id="@+id/import_as_favorites_row"

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="import_gpx_file_description">can be imported as Favorites points, or as track file.</string>
<string name="import_as_gpx">Import as GPX file</string>
<string name="import_as_favorites">Import as Favorites</string>
<string name="import_file">Import file</string>

View file

@ -541,29 +541,13 @@ public class GpxImportHelper {
if (forceImportFavourites) {
importFavoritesImpl(gpxFile, fileName, true);
} else {
final DialogInterface.OnClickListener importFavouritesListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
importFavoritesImpl(gpxFile, fileName, false);
break;
case DialogInterface.BUTTON_NEGATIVE:
handleResult(gpxFile, fileName, save, useImportDir, false);
break;
}
}
};
ImportGpxBottomSheetDialogFragment fragment = new ImportGpxBottomSheetDialogFragment();
fragment.setGpxImportHelper(this);
fragment.setGpxFile(gpxFile);
fragment.setFileName(fileName);
fragment.setSave(save);
fragment.setUseImportDir(useImportDir);
fragment.show(activity.getSupportFragmentManager(), ImportGpxBottomSheetDialogFragment.TAG);
// new AlertDialog.Builder(activity)
// .setTitle(R.string.shared_string_import2osmand)
// .setMessage(R.string.import_file_favourites)
// .setPositiveButton(R.string.shared_string_import, importFavouritesListener)
// .setNegativeButton(R.string.shared_string_save, importFavouritesListener)
// .show();
}
}
@ -622,9 +606,35 @@ public class GpxImportHelper {
public static final String TAG = "ImportGpxBottomSheetDialogFragment";
private GpxImportHelper gpxImportHelper;
private boolean portrait;
private boolean night;
private GPXFile gpxFile;
private String fileName;
private boolean save;
private boolean useImportDir;
public void setGpxImportHelper(GpxImportHelper gpxImportHelper) {
this.gpxImportHelper = gpxImportHelper;
}
public void setGpxFile(GPXFile gpxFile) {
this.gpxFile = gpxFile;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public void setSave(boolean save) {
this.save = save;
}
public void setUseImportDir(boolean useImportDir) {
this.useImportDir = useImportDir;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -644,16 +654,20 @@ public class GpxImportHelper {
((ImageView) mainView.findViewById(R.id.import_as_favorites_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_fav_dark));
((ImageView) mainView.findViewById(R.id.import_as_gpx_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark));
((TextView) mainView.findViewById(R.id.import_gpx_file_name_tv)).setText(fileName);
mainView.findViewById(R.id.import_as_favorites_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getActivity(), "Imropt as Favorites", Toast.LENGTH_SHORT).show();
gpxImportHelper.importFavoritesImpl(gpxFile, fileName, false);
dismiss();
}
});
mainView.findViewById(R.id.import_as_gpx_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getActivity(), "Imropt as GPX", Toast.LENGTH_SHORT).show();
gpxImportHelper.handleResult(gpxFile, fileName, save, useImportDir, false);
dismiss();
}
});