Merge subscriptions card fix
This commit is contained in:
parent
a341b9a91f
commit
a79649a4ef
3 changed files with 70 additions and 81 deletions
|
@ -183,32 +183,69 @@
|
|||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/div_button_settings"
|
||||
android:id="@+id/buttons_div"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="visible"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_settings"
|
||||
android:id="@+id/buttons_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="48dp"
|
||||
android:visibility="gone">
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_subscriptions_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="left|center_vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:gravity="right"
|
||||
android:id="@+id/button_subscriptions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:ellipsize="end"
|
||||
android:gravity="left|center_vertical"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/osm_live_subscriptions"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
app:textAllCapsCompat="true"
|
||||
app:typeface="@string/font_roboto_medium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_settings_container"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="right|center_vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/button_settings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="right|center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:lines="1"
|
||||
android:maxLines="1"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/shared_string_settings"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
app:textAllCapsCompat="true"
|
||||
app:typeface="@string/font_roboto_medium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -216,3 +253,5 @@
|
|||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -10,6 +10,8 @@
|
|||
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||
Thx - Hardy
|
||||
-->
|
||||
<string name="osm_live_subscriptions">Subscriptions</string>
|
||||
<string name="powered_by_osmand">Powered by OsmAnd</string>
|
||||
<string name="osm_live_plan_pricing">Plan & Pricing</string>
|
||||
<string name="osm_live_payment_monthly_title">Pay monthly</string>
|
||||
<string name="osm_live_payment_3_months_title">Pay once in 3 months</string>
|
||||
|
|
|
@ -16,21 +16,14 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AlertDialog.Builder;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ExpandableListView;
|
||||
|
@ -150,23 +143,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
|||
if (!Version.isDeveloperVersion(getMyApplication())) {
|
||||
subscriptionHeader = inflater.inflate(R.layout.live_updates_header, listView, false);
|
||||
updateSubscriptionHeader();
|
||||
|
||||
listView.addHeaderView(subscriptionHeader);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (position == 0 && !processing && InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
if (isDonationSupported()) {
|
||||
showDonationSettings();
|
||||
} else {
|
||||
ChoosePlanDialogFragment.showOsmLiveInstance(activity.getSupportFragmentManager());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
listView.addHeaderView(subscriptionHeader, "subscriptionHeader", false);
|
||||
}
|
||||
listView.setAdapter(adapter);
|
||||
|
||||
|
@ -212,20 +189,26 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
|||
}
|
||||
regionNameTextView.setText(countryName);
|
||||
|
||||
View divButtonSettings = subscriptionHeader.findViewById(R.id.div_button_settings);
|
||||
View buttonSettings = subscriptionHeader.findViewById(R.id.button_settings);
|
||||
View subscriptionsButton = subscriptionHeader.findViewById(R.id.button_subscriptions);
|
||||
View settingsButtonContainer = subscriptionHeader.findViewById(R.id.button_settings_container);
|
||||
View settingsButton = subscriptionHeader.findViewById(R.id.button_settings);
|
||||
subscriptionsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ChoosePlanDialogFragment.showOsmLiveInstance(getActivity().getSupportFragmentManager());
|
||||
}
|
||||
});
|
||||
if (isDonationSupported()) {
|
||||
buttonSettings.setOnClickListener(new View.OnClickListener() {
|
||||
settingsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showDonationSettings();
|
||||
}
|
||||
});
|
||||
divButtonSettings.setVisibility(View.VISIBLE);
|
||||
buttonSettings.setVisibility(View.VISIBLE);
|
||||
settingsButtonContainer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
divButtonSettings.setVisibility(View.GONE);
|
||||
buttonSettings.setVisibility(View.GONE);
|
||||
settingsButton.setOnClickListener(null);
|
||||
settingsButtonContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
subscriptionBanner.setVisibility(View.GONE);
|
||||
|
@ -286,41 +269,6 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())
|
||||
&& !Version.isDeveloperVersion(getMyApplication())) {
|
||||
|
||||
ActionBar actionBar = getMyActivity().getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
}
|
||||
|
||||
SubMenu split = menu.addSubMenu(R.string.shared_string_more_actions);
|
||||
split.setIcon(R.drawable.ic_overflow_menu_white);
|
||||
MenuItemCompat.setShowAsAction(split.getItem(), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
MenuItem item = split.add(0, SUBSCRIPTION_SETTINGS, 0, R.string.osm_live_subscription_settings);
|
||||
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == SUBSCRIPTION_SETTINGS && !processing) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
if (isDonationSupported()) {
|
||||
showDonationSettings();
|
||||
} else {
|
||||
ChoosePlanDialogFragment.showOsmLiveInstance(activity.getSupportFragmentManager());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private boolean isDonationSupported() {
|
||||
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
||||
if (purchaseHelper != null) {
|
||||
|
|
Loading…
Reference in a new issue