quick action widget land/keyboard resize screen/edit action bug fixed

This commit is contained in:
Rosty 2016-12-28 12:26:59 +02:00
parent 66440708be
commit 285ee3d266
6 changed files with 93 additions and 13 deletions

View file

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/quick_action_background">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/bg_card_light"
android:clickable="true"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="200dp" />
<LinearLayout
android:id="@+id/controls"
android:layout_width="match_parent"
android:layout_height="24dp"
android:background="@drawable/quick_action_controls_background"
android:orientation="horizontal">
<ImageButton
android:id="@+id/btnPrev"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?android:selectableItemBackground"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
<LinearLayout
android:id="@+id/dots"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" />
<ImageButton
android:id="@+id/btnNext"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?android:selectableItemBackground"
android:paddingLeft="16dp"
android:paddingRight="16dp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:grid="http://schemas.android.com/apk/res-auto"
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
grid:orientation="horizontal"
grid:alignmentMode="alignMargins"
grid:columnCount="6"/>

View file

@ -86,13 +86,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dashboard_background"
android:layout_marginBottom="56dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"
android:background="@color/dashboard_background"
android:layout_weight="1"
android:layout_marginBottom="56dp"/>
android:id="@+id/container"/>
</ScrollView>
<ImageView
android:layout_width="match_parent"

View file

@ -2,4 +2,7 @@
<resources>
<dimen name="first_usage_title_margin">50dp</dimen>
<dimen name="first_usage_title_text_size">30sp</dimen>
<dimen name="quick_action_widget_height_big">100dp</dimen>
<dimen name="quick_action_widget_height_small">100dp</dimen>
</resources>

View file

@ -183,7 +183,9 @@ public class CreateEditActionDialog extends DialogFragment {
action.fillParams();
quickActionRegistry.addQuickAction(action);
if (isNew) quickActionRegistry.addQuickAction(action);
else quickActionRegistry.updateQuickAction(action);
quickActionRegistry.notifyUpdates();
dismiss();

View file

@ -1,5 +1,6 @@
package net.osmand.plus.quickaction;
import android.app.Activity;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
@ -18,6 +19,7 @@ import android.widget.TextView;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.helpers.AndroidUiHelper;
import java.util.List;
@ -165,12 +167,7 @@ public class QuickActionsWidget extends LinearLayout {
View page = li.inflate(R.layout.quick_action_widget_page, container, false);
GridLayout gridLayout = (GridLayout) page.findViewById(R.id.grid);
// final int maxItems = position > 0
// ? ELEMENT_PER_PAGE
// : (actions.size() > (ELEMENT_PER_PAGE / 2)
// ? ELEMENT_PER_PAGE
// : (ELEMENT_PER_PAGE / 2));
final boolean land = !AndroidUiHelper.isOrientationPortrait((Activity) getContext());
final int maxItems = actions.size() == 1 ? 1 : ELEMENT_PER_PAGE;
for (int i = 0; i < maxItems; i++){
@ -197,8 +194,13 @@ public class QuickActionsWidget extends LinearLayout {
});
}
if (land) {
view.findViewById(R.id.dividerBot).setVisibility(GONE);
view.findViewById(R.id.dividerRight).setVisibility(VISIBLE);
} else {
view.findViewById(R.id.dividerBot).setVisibility(i < ELEMENT_PER_PAGE / 2 ? VISIBLE : GONE);
view.findViewById(R.id.dividerRight).setVisibility(((i + 1) % 3) == 0 ? GONE : VISIBLE);
}
gridLayout.addView(view);
}