Fix free version dialog
This commit is contained in:
parent
f09e99ca8c
commit
1c80a423b7
2 changed files with 27 additions and 21 deletions
|
@ -90,14 +90,16 @@
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="@color/dashboard_divider_dark"/>
|
android:background="@color/dashboard_divider_dark"
|
||||||
|
android:visibility="visible"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/fullVersionLayout"
|
android:id="@+id/fullVersionLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/list_content_padding"
|
android:layout_marginTop="@dimen/list_content_padding"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatImageView
|
<android.support.v7.widget.AppCompatImageView
|
||||||
android:layout_width="54dp"
|
android:layout_width="54dp"
|
||||||
|
@ -154,17 +156,20 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
android:id="@+id/osmLiveLayoutTopDivider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:layout_marginLeft="54dp"
|
android:layout_marginLeft="54dp"
|
||||||
android:layout_marginTop="@dimen/list_content_padding"
|
android:layout_marginTop="@dimen/list_content_padding"
|
||||||
android:background="@color/dashboard_divider_dark"/>
|
android:background="@color/dashboard_divider_dark"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/osmLiveLayout"
|
android:id="@+id/osmLiveLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/list_content_padding"
|
android:layout_marginTop="@dimen/list_content_padding"
|
||||||
|
android:layout_marginBottom="@dimen/list_content_padding"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<android.support.v7.widget.AppCompatImageView
|
<android.support.v7.widget.AppCompatImageView
|
||||||
|
@ -220,13 +225,6 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:layout_marginLeft="54dp"
|
|
||||||
android:layout_marginTop="@dimen/list_content_padding"
|
|
||||||
android:background="@color/dashboard_divider_dark"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,44 +1,52 @@
|
||||||
package net.osmand.plus.download.ui;
|
package net.osmand.plus.download.ui;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadActivity.FreeVersionDialog;
|
import net.osmand.plus.download.DownloadActivity.FreeVersionDialog;
|
||||||
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.plus.download.IndexItem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class FreeVersionDialogFragment extends DialogFragment {
|
public class FreeVersionDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
|
||||||
private FreeVersionDialog dialog;
|
private FreeVersionDialog dialog;
|
||||||
|
|
||||||
|
@SuppressLint("HardwareIds")
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setNegativeButton(R.string.later, null);
|
builder.setNegativeButton(R.string.later, null);
|
||||||
View view = getActivity().getLayoutInflater().inflate(R.layout.free_version_banner, null);
|
View view = getActivity().getLayoutInflater().inflate(R.layout.free_version_banner, null);
|
||||||
|
boolean hidePlus = false;
|
||||||
|
try {
|
||||||
|
String devId = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||||
|
if (!Algorithms.isEmpty(devId)) {
|
||||||
|
hidePlus = devId.hashCode() % 20 == 8;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
view.findViewById(R.id.osmLiveLayoutTopDivider).setVisibility(hidePlus ? View.GONE : View.VISIBLE);
|
||||||
|
view.findViewById(R.id.fullVersionLayout).setVisibility(hidePlus ? View.GONE : View.VISIBLE);
|
||||||
builder.setView(view);
|
builder.setView(view);
|
||||||
dialog = new DownloadActivity.FreeVersionDialog(view, getDownloadActivity(), true);
|
dialog = new DownloadActivity.FreeVersionDialog(view, getDownloadActivity(), true);
|
||||||
dialog.initFreeVersionBanner();
|
dialog.initFreeVersionBanner();
|
||||||
dialog.expandBanner();
|
dialog.expandBanner();
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DownloadActivity getDownloadActivity() {
|
DownloadActivity getDownloadActivity() {
|
||||||
return (DownloadActivity) getActivity();
|
return (DownloadActivity) getActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue