Revert "Removed subscription"

This reverts commit e6e14fae7d.
This commit is contained in:
M66B 2020-04-17 09:07:24 +02:00
parent 92e115abd0
commit 4b87c1ecf8
3 changed files with 182 additions and 37 deletions

View File

@ -64,6 +64,8 @@ public class ActivityPro extends AppCompatActivity {
private static final int SKU_SPEED_ID = 4;
private static final int SKU_THEME_ID = 5;
private static final int SKU_PRO1_ID = 6;
private static final int SKU_SUPPORT1_ID = 7;
private static final int SKU_SUPPORT2_ID = 8;
public static final String SKU_LOG = "log";
public static final String SKU_FILTER = "filter";
@ -71,6 +73,8 @@ public class ActivityPro extends AppCompatActivity {
public static final String SKU_SPEED = "speed";
public static final String SKU_THEME = "theme";
public static final String SKU_PRO1 = "pro1";
public static final String SKU_SUPPORT1 = "support1";
public static final String SKU_SUPPORT2 = "support2";
public static final String SKU_DONATION = "donation";
@Override
@ -94,6 +98,8 @@ public class ActivityPro extends AppCompatActivity {
TextView tvSpeedTitle = findViewById(R.id.tvSpeedTitle);
TextView tvThemeTitle = findViewById(R.id.tvThemeTitle);
TextView tvAllTitle = findViewById(R.id.tvAllTitle);
TextView tvDev1Title = findViewById(R.id.tvDev1Title);
TextView tvDev2Title = findViewById(R.id.tvDev2Title);
tvLogTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
tvFilterTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
@ -101,6 +107,8 @@ public class ActivityPro extends AppCompatActivity {
tvSpeedTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
tvThemeTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
tvAllTitle.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
tvDev1Title.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
tvDev2Title.setPaintFlags(tvLogTitle.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
View.OnClickListener listener = new View.OnClickListener() {
@Override
@ -125,6 +133,12 @@ public class ActivityPro extends AppCompatActivity {
case R.id.tvAllTitle:
sku = SKU_PRO1;
break;
case R.id.tvDev1Title:
sku = SKU_SUPPORT1;
break;
case R.id.tvDev2Title:
sku = SKU_SUPPORT2;
break;
default:
sku = SKU_PRO1;
break;
@ -143,6 +157,8 @@ public class ActivityPro extends AppCompatActivity {
tvSpeedTitle.setOnClickListener(listener);
tvThemeTitle.setOnClickListener(listener);
tvAllTitle.setOnClickListener(listener);
tvDev1Title.setOnClickListener(listener);
tvDev2Title.setOnClickListener(listener);
try {
iab = new IAB(new IAB.Delegate() {
@ -159,6 +175,8 @@ public class ActivityPro extends AppCompatActivity {
final Button btnSpeed = findViewById(R.id.btnSpeed);
final Button btnTheme = findViewById(R.id.btnTheme);
final Button btnAll = findViewById(R.id.btnAll);
final Button btnDev1 = findViewById(R.id.btnDev1);
final Button btnDev2 = findViewById(R.id.btnDev2);
View.OnClickListener listener = new View.OnClickListener() {
@Override
@ -184,6 +202,12 @@ public class ActivityPro extends AppCompatActivity {
} else if (view == btnAll) {
id = SKU_PRO1_ID;
pi = iab.getBuyIntent(SKU_PRO1, false);
} else if (view == btnDev1) {
id = SKU_SUPPORT1_ID;
pi = iab.getBuyIntent(SKU_SUPPORT1, true);
} else if (view == btnDev2) {
id = SKU_SUPPORT2_ID;
pi = iab.getBuyIntent(SKU_SUPPORT2, true);
}
if (id > 0 && pi != null)
@ -200,6 +224,8 @@ public class ActivityPro extends AppCompatActivity {
btnSpeed.setOnClickListener(listener);
btnTheme.setOnClickListener(listener);
btnAll.setOnClickListener(listener);
btnDev1.setOnClickListener(listener);
btnDev2.setOnClickListener(listener);
btnLog.setEnabled(true);
btnFilter.setEnabled(true);
@ -207,6 +233,8 @@ public class ActivityPro extends AppCompatActivity {
btnSpeed.setEnabled(true);
btnTheme.setEnabled(true);
btnAll.setEnabled(true);
btnDev1.setEnabled(true);
btnDev2.setEnabled(true);
} catch (Throwable ex) {
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
@ -360,6 +388,14 @@ public class ActivityPro extends AppCompatActivity {
IAB.setBought(SKU_PRO1, this);
updateState();
break;
case SKU_SUPPORT1_ID:
IAB.setBought(SKU_SUPPORT1, this);
updateState();
break;
case SKU_SUPPORT2_ID:
IAB.setBought(SKU_SUPPORT2, this);
updateState();
break;
}
}
}
@ -371,12 +407,16 @@ public class ActivityPro extends AppCompatActivity {
Button btnSpeed = findViewById(R.id.btnSpeed);
Button btnTheme = findViewById(R.id.btnTheme);
Button btnAll = findViewById(R.id.btnAll);
Button btnDev1 = findViewById(R.id.btnDev1);
Button btnDev2 = findViewById(R.id.btnDev2);
TextView tvLog = findViewById(R.id.tvLog);
TextView tvFilter = findViewById(R.id.tvFilter);
TextView tvNotify = findViewById(R.id.tvNotify);
TextView tvSpeed = findViewById(R.id.tvSpeed);
TextView tvTheme = findViewById(R.id.tvTheme);
TextView tvAll = findViewById(R.id.tvAll);
TextView tvDev1 = findViewById(R.id.tvDev1);
TextView tvDev2 = findViewById(R.id.tvDev2);
TextView tvLogUnavailable = findViewById(R.id.tvLogUnavailable);
TextView tvFilterUnavailable = findViewById(R.id.tvFilterUnavailable);
@ -389,6 +429,8 @@ public class ActivityPro extends AppCompatActivity {
btnSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.GONE : View.VISIBLE);
btnTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.GONE : View.VISIBLE);
btnAll.setVisibility(IAB.isPurchased(SKU_PRO1, this) ? View.GONE : View.VISIBLE);
btnDev1.setVisibility(IAB.isPurchased(SKU_SUPPORT1, this) ? View.GONE : View.VISIBLE);
btnDev2.setVisibility(IAB.isPurchased(SKU_SUPPORT2, this) ? View.GONE : View.VISIBLE);
tvLog.setVisibility(IAB.isPurchased(SKU_LOG, this) && can ? View.VISIBLE : View.GONE);
tvFilter.setVisibility(IAB.isPurchased(SKU_FILTER, this) && can ? View.VISIBLE : View.GONE);
@ -396,6 +438,8 @@ public class ActivityPro extends AppCompatActivity {
tvSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.VISIBLE : View.GONE);
tvTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.VISIBLE : View.GONE);
tvAll.setVisibility(IAB.isPurchased(SKU_PRO1, this) ? View.VISIBLE : View.GONE);
tvDev1.setVisibility(IAB.isPurchased(SKU_SUPPORT1, this) ? View.VISIBLE : View.GONE);
tvDev2.setVisibility(IAB.isPurchased(SKU_SUPPORT2, this) ? View.VISIBLE : View.GONE);
tvLogUnavailable.setVisibility(can ? View.GONE : View.VISIBLE);
tvFilterUnavailable.setVisibility(can ? View.GONE : View.VISIBLE);

View File

@ -181,6 +181,9 @@ public class IAB implements ServiceConnection {
}
SharedPreferences prefs = context.getSharedPreferences("IAB", Context.MODE_PRIVATE);
if (ActivityPro.SKU_SUPPORT1.equals(sku) || ActivityPro.SKU_SUPPORT2.equals(sku))
return prefs.getBoolean(sku, false);
return (prefs.getBoolean(sku, false) ||
prefs.getBoolean(ActivityPro.SKU_PRO1, false) ||
prefs.getBoolean(ActivityPro.SKU_DONATION, false));

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
tools:context=".ActivityPro">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
tools:context=".ActivityPro">
<LinearLayout
android:layout_width="match_parent"
@ -16,14 +16,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_pro_description"
android:textAppearance="@style/TextMedium" />
android:textAppearance="@style/TextMedium"/>
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:layout_marginTop="8dip"
android:layout_marginBottom="8dip"
android:background="@android:color/darker_gray" />
android:layout_marginTop="8dip"
android:background="@android:color/darker_gray"/>
<LinearLayout
android:layout_width="match_parent"
@ -38,7 +38,7 @@
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:text="@string/title_pro_log"
android:textAppearance="@style/TextSmall" />
android:textAppearance="@style/TextSmall"/>
<Button
android:id="@+id/btnLog"
@ -48,7 +48,7 @@
android:layout_weight="1"
android:enabled="false"
android:text="@string/title_pro_buy"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/tvLog"
@ -60,7 +60,7 @@
android:text="@string/title_pro_bought"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/tvLogUnavailable"
@ -72,7 +72,7 @@
android:text="@string/title_pro_unavailable"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone" />
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
@ -88,7 +88,7 @@
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:text="@string/title_pro_filter"
android:textAppearance="@style/TextSmall" />
android:textAppearance="@style/TextSmall"/>
<Button
android:id="@+id/btnFilter"
@ -98,7 +98,7 @@
android:layout_weight="1"
android:enabled="false"
android:text="@string/title_pro_buy"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/tvFilter"
@ -110,7 +110,7 @@
android:text="@string/title_pro_bought"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/tvFilterUnavailable"
@ -122,7 +122,7 @@
android:text="@string/title_pro_unavailable"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone" />
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
@ -138,7 +138,7 @@
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:text="@string/title_pro_notify"
android:textAppearance="@style/TextSmall" />
android:textAppearance="@style/TextSmall"/>
<Button
android:id="@+id/btnNotify"
@ -148,7 +148,7 @@
android:layout_weight="1"
android:enabled="false"
android:text="@string/title_pro_buy"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/tvNotify"
@ -160,7 +160,7 @@
android:text="@string/title_pro_bought"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone" />
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
@ -176,7 +176,7 @@
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:text="@string/title_pro_speed"
android:textAppearance="@style/TextSmall" />
android:textAppearance="@style/TextSmall"/>
<Button
android:id="@+id/btnSpeed"
@ -186,7 +186,7 @@
android:layout_weight="1"
android:enabled="false"
android:text="@string/title_pro_buy"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/tvSpeed"
@ -198,7 +198,7 @@
android:text="@string/title_pro_bought"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone" />
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
@ -214,7 +214,7 @@
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:text="@string/title_pro_theme"
android:textAppearance="@style/TextSmall" />
android:textAppearance="@style/TextSmall"/>
<Button
android:id="@+id/btnTheme"
@ -224,7 +224,7 @@
android:layout_weight="1"
android:enabled="false"
android:text="@string/title_pro_buy"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/tvTheme"
@ -236,15 +236,15 @@
android:text="@string/title_pro_bought"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone" />
android:visibility="gone"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:layout_marginTop="8dip"
android:layout_marginBottom="8dip"
android:background="@android:color/darker_gray" />
android:layout_marginTop="8dip"
android:background="@android:color/darker_gray"/>
<TextView
android:layout_width="match_parent"
@ -252,14 +252,14 @@
android:gravity="center_horizontal"
android:text="="
android:textAppearance="@style/TextLarge"
android:textSize="36sp" />
android:textSize="36sp"/>
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:layout_marginTop="8dip"
android:layout_marginBottom="8dip"
android:background="@android:color/darker_gray" />
android:layout_marginTop="8dip"
android:background="@android:color/darker_gray"/>
<LinearLayout
android:layout_width="match_parent"
@ -274,7 +274,7 @@
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:text="@string/title_pro_all"
android:textAppearance="@style/TextSmall" />
android:textAppearance="@style/TextSmall"/>
<Button
android:id="@+id/btnAll"
@ -284,7 +284,7 @@
android:layout_weight="1"
android:enabled="false"
android:text="@string/title_pro_buy"
android:visibility="gone" />
android:visibility="gone"/>
<TextView
android:id="@+id/tvAll"
@ -296,21 +296,119 @@
android:text="@string/title_pro_bought"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone" />
android:visibility="gone"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:layout_marginTop="8dip"
android:layout_marginBottom="8dip"
android:background="@android:color/darker_gray" />
android:layout_marginTop="8dip"
android:background="@android:color/darker_gray"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="≠"
android:textAppearance="@style/TextLarge"
android:textSize="36sp"/>
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:layout_marginBottom="8dip"
android:layout_marginTop="8dip"
android:background="@android:color/darker_gray"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:orientation="horizontal">
<TextView
android:id="@+id/tvDev1Title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:text="@string/title_pro_dev"
android:textAppearance="@style/TextSmall"/>
<Button
android:id="@+id/btnDev1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="1"
android:enabled="false"
android:text="@string/title_pro_buy"
android:visibility="gone"/>
<TextView
android:id="@+id/tvDev1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="@string/title_pro_bought"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:orientation="horizontal">
<TextView
android:id="@+id/tvDev2Title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:text="@string/title_pro_dev"
android:textAppearance="@style/TextSmall"/>
<Button
android:id="@+id/btnDev2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_weight="1"
android:enabled="false"
android:text="@string/title_pro_buy"
android:visibility="gone"/>
<TextView
android:id="@+id/tvDev2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="@string/title_pro_bought"
android:textAppearance="@style/TextMedium"
android:textStyle="bold"
android:visibility="gone"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:layout_marginBottom="8dip"
android:layout_marginTop="8dip"
android:background="@android:color/darker_gray"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/title_pro_details"
android:textAppearance="@style/TextMedium" />
android:textAppearance="@style/TextMedium"/>
</LinearLayout>
</ScrollView>