forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'organicmaps:master' into master
- Loading branch information
Showing
93 changed files
with
1,264 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
android/app/src/main/java/app/organicmaps/editor/SelfServiceAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package app.organicmaps.editor; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.CompoundButton; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import app.organicmaps.R; | ||
import app.organicmaps.util.UiUtils; | ||
import app.organicmaps.util.Utils; | ||
|
||
public class SelfServiceAdapter extends RecyclerView.Adapter<SelfServiceAdapter.ViewHolder> | ||
{ | ||
private final String[] mItems = new String[]{"yes", "only", "partially", "no"}; | ||
private final SelfServiceFragment mFragment; | ||
private String mSelectedOption; | ||
|
||
|
||
public SelfServiceAdapter(@NonNull SelfServiceFragment host, @NonNull String selected) | ||
{ | ||
mFragment = host; | ||
mSelectedOption = selected; | ||
} | ||
|
||
public String getSelected() | ||
{ | ||
return mSelectedOption; | ||
} | ||
|
||
@Override | ||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) | ||
{ | ||
return new SelfServiceAdapter.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_selection, parent, false)); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(SelfServiceAdapter.ViewHolder holder, int position) | ||
{ | ||
holder.bind(position); | ||
} | ||
|
||
@Override | ||
public int getItemCount() | ||
{ | ||
return mItems.length; | ||
} | ||
|
||
protected class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener | ||
{ | ||
final TextView selfServiceDef; | ||
final CompoundButton selected; | ||
|
||
public ViewHolder(View itemView) | ||
{ | ||
super(itemView); | ||
selfServiceDef = itemView.findViewById(R.id.self_service_default); | ||
selected = itemView.findViewById(R.id.self_service_selected); | ||
itemView.setOnClickListener(this); | ||
selected.setOnClickListener(v -> { | ||
selected.toggle(); | ||
SelfServiceAdapter.ViewHolder.this.onClick(selected); | ||
}); | ||
} | ||
|
||
public void bind(int position) | ||
{ | ||
Context context = itemView.getContext(); | ||
selected.setChecked(mSelectedOption.equals(mItems[position])); | ||
String text = Utils.getTagValueLocalized(context, "self_service", mItems[position]); | ||
selfServiceDef.setText(text); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) | ||
{ | ||
mSelectedOption = mItems[getBindingAdapterPosition()]; | ||
notifyDataSetChanged(); | ||
mFragment.saveSelection(mSelectedOption); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
android/app/src/main/java/app/organicmaps/editor/SelfServiceFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package app.organicmaps.editor; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.CallSuper; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import app.organicmaps.base.BaseMwmRecyclerFragment; | ||
import app.organicmaps.bookmarks.data.Metadata; | ||
import app.organicmaps.editor.data.LocalizedStreet; | ||
|
||
public class SelfServiceFragment extends BaseMwmRecyclerFragment<SelfServiceAdapter> | ||
{ | ||
private String mSelectedString; | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) | ||
{ | ||
return super.onCreateView(inflater, container, savedInstanceState); | ||
} | ||
|
||
@NonNull | ||
public String getSelection() | ||
{ | ||
return getAdapter().getSelected(); | ||
} | ||
|
||
@CallSuper | ||
@Override | ||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) | ||
{ | ||
mSelectedString = Editor.nativeGetMetadata(Metadata.MetadataType.FMD_SELF_SERVICE.toInt()); | ||
super.onViewCreated(view, savedInstanceState); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
protected SelfServiceAdapter createAdapter() | ||
{ | ||
return new SelfServiceAdapter(this, mSelectedString); | ||
} | ||
|
||
protected void saveSelection(String selection) | ||
{ | ||
if (getParentFragment() instanceof EditorHostFragment) | ||
((EditorHostFragment) getParentFragment()).setSelection(Metadata.MetadataType.FMD_SELF_SERVICE, selection); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
android/app/src/main/java/app/organicmaps/maplayer/LayersButton.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package app.organicmaps.maplayer; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
|
||
import com.google.android.material.floatingactionbutton.FloatingActionButton; | ||
|
||
import app.organicmaps.R; | ||
|
||
public class LayersButton extends FloatingActionButton | ||
{ | ||
private boolean mAreLayersActive = false; | ||
|
||
public LayersButton(Context context) | ||
{ | ||
super(context); | ||
} | ||
|
||
public LayersButton(Context context, AttributeSet attrs) | ||
{ | ||
super(context, attrs); | ||
} | ||
|
||
public LayersButton(Context context, AttributeSet attrs, int defStyleAttr) | ||
{ | ||
super(context, attrs, defStyleAttr); | ||
} | ||
|
||
@Override | ||
public int[] onCreateDrawableState(int extraSpace) | ||
{ | ||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); | ||
if (mAreLayersActive) | ||
mergeDrawableStates(drawableState, new int[]{R.attr.layers_enabled}); | ||
return drawableState; | ||
} | ||
|
||
public void setHasActiveLayers(boolean areLayersActive) | ||
{ | ||
mAreLayersActive = areLayersActive; | ||
refreshDrawableState(); | ||
} | ||
} |
Oops, something went wrong.