Add ability to disable plugin inside install dialog and fix UI bugs
This commit is contained in:
parent
8832a27a8e
commit
c01c979102
10 changed files with 69 additions and 16 deletions
|
@ -6,7 +6,7 @@
|
|||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/route_info_list_text_padding">
|
||||
android:paddingBottom="@dimen/dialog_button_height">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -27,15 +27,18 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/dialog_content_margin"
|
||||
android:paddingLeft="@dimen/dialog_content_margin">
|
||||
android:layout_marginStart="@dimen/dialog_content_margin"
|
||||
android:layout_marginLeft="@dimen/dialog_content_margin"
|
||||
android:layout_marginTop="@dimen/content_padding_small"
|
||||
android:layout_marginEnd="@dimen/content_padding_small"
|
||||
android:layout_marginRight="@dimen/content_padding_small"
|
||||
android:layout_marginBottom="@dimen/content_padding_small"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/content_padding_small"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/permission_is_required" />
|
||||
|
@ -47,7 +50,6 @@
|
|||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:paddingTop="@dimen/content_padding_small"
|
||||
android:paddingBottom="@dimen/content_padding_small"
|
||||
android:textColor="?attr/active_color_basic"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
android:title="@string/accessibility_mode_disabled" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
android:icon="@drawable/ic_action_android"
|
||||
android:key="accessibility_mode"
|
||||
android:layout="@layout/preference_with_descr"
|
||||
android:title="@string/accessibility_mode"
|
||||
tools:icon="@drawable/ic_action_android"
|
||||
tools:summary="@string/accessibility_default" />
|
||||
|
||||
<net.osmand.plus.settings.preferences.ListPreferenceEx
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.support.v7.preference.PreferenceViewHolder;
|
|||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
|
@ -126,6 +127,7 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
ListPreferenceEx accessibilityMode = (ListPreferenceEx) findPreference(settings.ACCESSIBILITY_MODE.getId());
|
||||
accessibilityMode.setEntries(entries);
|
||||
accessibilityMode.setEntryValues(entryValues);
|
||||
accessibilityMode.setIcon(getPersistentPrefIcon(R.drawable.ic_action_android));
|
||||
accessibilityMode.setDescription(R.string.accessibility_mode_descr);
|
||||
}
|
||||
|
||||
|
@ -222,7 +224,8 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
@Override
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
super.onBindPreferenceViewHolder(preference, holder);
|
||||
if (ACCESSIBILITY_OPTIONS.equals(preference.getKey())) {
|
||||
String prefId = preference.getKey();
|
||||
if (ACCESSIBILITY_OPTIONS.equals(prefId)) {
|
||||
View selectableView = holder.itemView.findViewById(R.id.selectable_list_item);
|
||||
if (selectableView != null) {
|
||||
int color = AndroidUtils.getColorFromAttr(app, R.attr.activity_background_color);
|
||||
|
@ -240,6 +243,12 @@ public class AccessibilitySettingsFragment extends BaseSettingsFragment implemen
|
|||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) selectableView.getLayoutParams();
|
||||
params.setMargins(params.leftMargin, AndroidUtils.dpToPx(app, 6), params.rightMargin, params.bottomMargin);
|
||||
}
|
||||
} else if (settings.ACCESSIBILITY_MODE.getId().equals(prefId)) {
|
||||
ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon);
|
||||
if (imageView != null) {
|
||||
boolean enabled = preference.isEnabled() && app.accessibilityEnabledForMode(getSelectedAppMode());
|
||||
imageView.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,10 +20,11 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
|
||||
import net.osmand.plus.dialogs.PluginInstalledBottomSheetDialog;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
|
||||
public class PluginActivity extends OsmandActionBarActivity implements DownloadIndexesThread.DownloadEvents {
|
||||
public class PluginActivity extends OsmandActionBarActivity implements DownloadIndexesThread.DownloadEvents, PluginInstalledBottomSheetDialog.PluginStateListener {
|
||||
private static final String TAG = "PluginActivity";
|
||||
public static final String EXTRA_PLUGIN_ID = "plugin_id";
|
||||
|
||||
|
@ -214,4 +215,9 @@ public class PluginActivity extends OsmandActionBarActivity implements Download
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginStateChanged(OsmandPlugin plugin) {
|
||||
updateState();
|
||||
}
|
||||
}
|
|
@ -21,11 +21,12 @@ import net.osmand.aidl.ConnectedApp;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.dialogs.PluginInstalledBottomSheetDialog;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PluginsActivity extends OsmandListActivity implements DownloadIndexesThread.DownloadEvents {
|
||||
public class PluginsActivity extends OsmandListActivity implements DownloadIndexesThread.DownloadEvents, PluginInstalledBottomSheetDialog.PluginStateListener {
|
||||
|
||||
public static final int ACTIVE_PLUGINS_LIST_MODIFIED = 1;
|
||||
|
||||
|
@ -119,6 +120,11 @@ public class PluginsActivity extends OsmandListActivity implements DownloadIndex
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginStateChanged(OsmandPlugin plugin) {
|
||||
getListAdapter().notifyDataSetChanged();
|
||||
}
|
||||
|
||||
protected class PluginsListAdapter extends ArrayAdapter<Object> {
|
||||
|
||||
PluginsListAdapter() {
|
||||
|
|
|
@ -62,6 +62,7 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
|
||||
private static final Log log = PlatformUtil.getLog(MultimediaNotesFragment.class);
|
||||
|
||||
private static final String OPEN_NOTES_DESCRIPTION = "open_notes_description";
|
||||
private static final String CAMERA_PERMISSION = "camera_permission";
|
||||
private static final String COPY_PLUGIN_SETTINGS = "copy_plugin_settings";
|
||||
private static final String RESET_TO_DEFAULT = "reset_to_default";
|
||||
|
@ -244,9 +245,13 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
}
|
||||
|
||||
private void setupPhotoPlaySoundPref(Camera cam, AudioVideoNotesPlugin plugin) {
|
||||
Drawable disabled = getContentIcon(R.drawable.ic_action_music_off);
|
||||
Drawable enabled = getActiveIcon(R.drawable.ic_type_audio);
|
||||
Drawable icon = getPersistentPrefIcon(enabled, disabled);
|
||||
|
||||
SwitchPreferenceEx photoPlaySound = (SwitchPreferenceEx) findPreference(plugin.AV_PHOTO_PLAY_SOUND.getId());
|
||||
photoPlaySound.setDescription(getString(R.string.av_photo_play_sound_descr));
|
||||
photoPlaySound.setIcon(getPersistentPrefIcon(R.drawable.ic_action_music_off));
|
||||
photoPlaySound.setIcon(icon);
|
||||
photoPlaySound.setEnabled(cam != null);
|
||||
}
|
||||
|
||||
|
@ -384,7 +389,7 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
Typeface typeface = FontCache.getRobotoMedium(getContext());
|
||||
titleSpan.setSpan(new CustomTypefaceSpan(typeface), startIndex, startIndex + multimediaNotesPath.length(), 0);
|
||||
|
||||
Preference osmEditsDescription = findPreference("open_notes_description");
|
||||
Preference osmEditsDescription = findPreference(OPEN_NOTES_DESCRIPTION);
|
||||
osmEditsDescription.setTitle(titleSpan);
|
||||
}
|
||||
|
||||
|
@ -444,7 +449,8 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
@Override
|
||||
protected void onBindPreferenceViewHolder(Preference preference, PreferenceViewHolder holder) {
|
||||
super.onBindPreferenceViewHolder(preference, holder);
|
||||
if (CAMERA_PERMISSION.equals(preference.getKey())) {
|
||||
String prefId = preference.getKey();
|
||||
if (CAMERA_PERMISSION.equals(prefId)) {
|
||||
View selectableView = holder.itemView.findViewById(R.id.selectable_list_item);
|
||||
if (selectableView != null) {
|
||||
int color = AndroidUtils.getColorFromAttr(app, R.attr.activity_background_color);
|
||||
|
@ -460,6 +466,9 @@ public class MultimediaNotesFragment extends BaseSettingsFragment implements Cop
|
|||
AndroidUtils.setBackground(selectableView, bgDrawable);
|
||||
}
|
||||
}
|
||||
} else if (OPEN_NOTES_DESCRIPTION.equals(prefId)) {
|
||||
int minHeight = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_list_item_height);
|
||||
holder.itemView.setMinimumHeight(minHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -162,6 +162,20 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
|||
return R.string.shared_string_turn_off;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDismissButtonClickAction() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
OsmandPlugin plugin = OsmandPlugin.getPlugin(pluginId);
|
||||
if (app != null && plugin != null) {
|
||||
Activity activity = getActivity();
|
||||
OsmandPlugin.enablePlugin(activity, app, plugin, false);
|
||||
|
||||
if (activity instanceof PluginStateListener) {
|
||||
((PluginStateListener) activity).onPluginStateChanged(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRightBottomButtonTextId() {
|
||||
return R.string.shared_string_ok;
|
||||
|
@ -307,4 +321,10 @@ public class PluginInstalledBottomSheetDialog extends MenuBottomSheetDialogFragm
|
|||
LOG.error("showInstance", e);
|
||||
}
|
||||
}
|
||||
|
||||
public interface PluginStateListener {
|
||||
|
||||
void onPluginStateChanged(OsmandPlugin plugin);
|
||||
|
||||
}
|
||||
}
|
|
@ -118,6 +118,7 @@ public class NavigationFragment extends BaseSettingsFragment {
|
|||
}
|
||||
bundle.putString(DIALOG_TYPE, TYPE_NAV_PROFILE);
|
||||
dialog.setArguments(bundle);
|
||||
dialog.setUsedOnMap(false);
|
||||
if (getActivity() != null) {
|
||||
getActivity().getSupportFragmentManager().beginTransaction()
|
||||
.add(dialog, "select_nav_type").commitAllowingStateLoss();
|
||||
|
|
|
@ -53,7 +53,7 @@ public class EditTextPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
RelativeLayout editTextLayout = view.findViewById(R.id.text_field_boxes_editTextLayout);
|
||||
if (editTextLayout != null && editTextLayout.getLayoutParams() instanceof RelativeLayout.LayoutParams) {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) editTextLayout.getLayoutParams();
|
||||
params.setMargins(params.leftMargin, AndroidUtils.dpToPx(ctx, 19), params.rightMargin, params.bottomMargin);
|
||||
params.setMargins(params.leftMargin, AndroidUtils.dpToPx(ctx, 9), params.rightMargin, params.bottomMargin);
|
||||
}
|
||||
|
||||
items.add(new SimpleBottomSheetItem.Builder().setCustomView(view).create());
|
||||
|
|
Loading…
Reference in a new issue