Replaced BuyDialog with PurchaseActivity

This commit is contained in:
Karim Abou Zeid 2017-09-02 19:20:30 +02:00
commit 035792b3d0
16 changed files with 349 additions and 215 deletions

View file

@ -75,7 +75,6 @@ ext {
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:support-compat:$supportLibVersion" compile "com.android.support:support-compat:$supportLibVersion"
compile "com.android.support:support-core-utils:$supportLibVersion" compile "com.android.support:support-core-utils:$supportLibVersion"
@ -94,19 +93,18 @@ dependencies {
compile "com.android.support:preference-v7:$supportLibVersion" compile "com.android.support:preference-v7:$supportLibVersion"
compile "com.android.support:preference-v14:$supportLibVersion" compile "com.android.support:preference-v14:$supportLibVersion"
compile 'com.crashlytics.sdk.android:crashlytics:2.6.7' // compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.6'
// TODO: go back to master branch as soon as possible
compile 'com.crashlytics.sdk.android:crashlytics:2.6.7'
compile 'com.github.kabouzeid:app-theme-helper:1.3.7' compile 'com.github.kabouzeid:app-theme-helper:1.3.7'
compile 'com.github.kabouzeid:RecyclerView-FastScroll:1.0.16-kmod' compile 'com.github.kabouzeid:RecyclerView-FastScroll:1.0.16-kmod'
compile 'com.github.kabouzeid:SeekArc:1.2-kmod' compile 'com.github.kabouzeid:SeekArc:1.2-kmod'
compile 'com.github.kabouzeid:AndroidSlidingUpPanel:3.3.0-kmod3' compile 'com.github.kabouzeid:AndroidSlidingUpPanel:3.3.0-kmod3'
compile 'com.afollestad.material-dialogs:core:0.9.4.5' compile 'com.afollestad.material-dialogs:core:0.9.4.5'
compile 'com.afollestad.material-dialogs:commons:0.9.4.5' compile 'com.afollestad.material-dialogs:commons:0.9.4.5'
compile 'com.afollestad:material-cab:0.1.12' compile 'com.afollestad:material-cab:0.1.12'
compile 'com.github.h6ah4i:android-advancedrecyclerview:feature~support_libraries_v26-SNAPSHOT'
// compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.6'
compile 'com.github.h6ah4i:android-advancedrecyclerview:feature~support_libraries_v26-SNAPSHOT' // TODO: go back to master branch as soon as possible
compile 'com.github.ksoichiro:android-observablescrollview:1.6.0' compile 'com.github.ksoichiro:android-observablescrollview:1.6.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.3.0'
@ -117,7 +115,8 @@ dependencies {
compile 'com.heinrichreimersoftware:material-intro:1.6.2' compile 'com.heinrichreimersoftware:material-intro:1.6.2'
compile 'me.zhanghai.android.materialprogressbar:library:1.4.1' compile 'me.zhanghai.android.materialprogressbar:library:1.4.1'
compile 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5' compile 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5'
compile 'com.jakewharton:butterknife:8.6.0' compile 'com.jakewharton:butterknife:8.6.0'
compile 'com.android.support.constraint:constraint-layout:+'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0' annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
} }

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest package="com.kabouzeid.gramophone"
xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kabouzeid.gramophone"> xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
@ -21,7 +21,6 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Phonograph.Light" android:theme="@style/Theme.Phonograph.Light"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<activity android:name=".ui.activities.MainActivity"> <activity android:name=".ui.activities.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -203,6 +202,7 @@
android:resource="@xml/app_widget_card_info" /> android:resource="@xml/app_widget_card_info" />
</receiver> </receiver>
<activity android:name=".ui.activities.PurchaseActivity"></activity>
</application> </application>
</manifest> </manifest>

View file

@ -49,7 +49,7 @@ public class App extends Application {
@Override @Override
public void onPurchaseHistoryRestored() { public void onPurchaseHistoryRestored() {
Toast.makeText(App.this, R.string.restored_previous_purchases_please_restart, Toast.LENGTH_LONG).show(); Toast.makeText(App.this, R.string.restored_previous_purchase_please_restart, Toast.LENGTH_LONG).show();
} }
@Override @Override
@ -63,7 +63,7 @@ public class App extends Application {
} }
public static boolean isProVersion() { public static boolean isProVersion() {
return BuildConfig.DEBUG || app.billingProcessor.isPurchased(PRO_VERSION_PRODUCT_ID); return app.billingProcessor.isPurchased(PRO_VERSION_PRODUCT_ID);
} }
@Override @Override

View file

@ -1,135 +0,0 @@
package com.kabouzeid.gramophone.dialogs;
import android.app.Dialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.widget.Toast;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.afollestad.materialdialogs.internal.MDButton;
import com.anjlab.android.iab.v3.BillingProcessor;
import com.anjlab.android.iab.v3.SkuDetails;
import com.anjlab.android.iab.v3.TransactionDetails;
import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.BuildConfig;
import com.kabouzeid.gramophone.R;
import java.lang.ref.WeakReference;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public class BuyDialog extends DialogFragment implements BillingProcessor.IBillingHandler {
public static final String TAG = BuyDialog.class.getSimpleName();
private BillingProcessor billingProcessor;
private AsyncTask skuDetailsLoadAsyncTask;
public static BuyDialog create() {
return new BuyDialog();
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
billingProcessor = new BillingProcessor(getContext(), App.GOOGLE_PLAY_LICENSE_KEY, this);
return new MaterialDialog.Builder(getContext())
.title(R.string.buy_pro)
.content("Unlock all features, such as:\n• Folder view\n• All theme colors\n• Black theme\n• Sleep timer")
.positiveText(R.string.buy)
.onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
billingProcessor.purchase(getActivity(), App.PRO_VERSION_PRODUCT_ID);
}
})
.build();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!billingProcessor.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void onProductPurchased(String productId, TransactionDetails details) {
loadSkuDetails();
Toast.makeText(getContext(), R.string.thank_you, Toast.LENGTH_SHORT).show();
}
@Override
public void onPurchaseHistoryRestored() {
loadSkuDetails();
Toast.makeText(getContext(), R.string.restored_previous_purchases_please_restart, Toast.LENGTH_LONG).show();
}
@Override
public void onBillingError(int errorCode, Throwable error) {
Log.e(TAG, "Billing error: code = " + errorCode, error);
}
@Override
public void onBillingInitialized() {
loadSkuDetails();
}
@Override
public void onDestroy() {
if (billingProcessor != null) {
billingProcessor.release();
}
if (skuDetailsLoadAsyncTask != null) {
skuDetailsLoadAsyncTask.cancel(true);
}
super.onDestroy();
}
private void loadSkuDetails() {
if (skuDetailsLoadAsyncTask != null) {
skuDetailsLoadAsyncTask.cancel(false);
}
skuDetailsLoadAsyncTask = new SkuDetailsLoadAsyncTask(this).execute();
}
private static class SkuDetailsLoadAsyncTask extends AsyncTask<Void, Void, SkuDetails> {
private final WeakReference<BuyDialog> donationDialogWeakReference;
public SkuDetailsLoadAsyncTask(BuyDialog donationsDialog) {
this.donationDialogWeakReference = new WeakReference<>(donationsDialog);
}
@Override
protected SkuDetails doInBackground(Void... params) {
BuyDialog dialog = donationDialogWeakReference.get();
if (dialog != null) {
return dialog.billingProcessor.getPurchaseListingDetails(App.PRO_VERSION_PRODUCT_ID);
}
cancel(false);
return null;
}
@Override
protected void onPostExecute(SkuDetails skuDetails) {
super.onPostExecute(skuDetails);
BuyDialog dialog = donationDialogWeakReference.get();
if (dialog == null) return;
if (skuDetails == null) {
if (!BuildConfig.DEBUG) dialog.dismiss();
return;
}
MDButton positiveButton = ((MaterialDialog) dialog.getDialog()).getActionButton(DialogAction.POSITIVE);
positiveButton.setText(String.format("%s %s", dialog.getString(R.string.buy), skuDetails.priceText));
}
}
}

View file

@ -21,6 +21,7 @@ import com.afollestad.materialdialogs.internal.ThemeSingleton;
import com.kabouzeid.gramophone.App; import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R; import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.service.MusicService; import com.kabouzeid.gramophone.service.MusicService;
import com.kabouzeid.gramophone.ui.activities.PurchaseActivity;
import com.kabouzeid.gramophone.util.MusicUtil; import com.kabouzeid.gramophone.util.MusicUtil;
import com.kabouzeid.gramophone.util.PreferenceUtil; import com.kabouzeid.gramophone.util.PreferenceUtil;
import com.triggertrap.seekarc.SeekArc; import com.triggertrap.seekarc.SeekArc;
@ -62,8 +63,7 @@ public class SleepTimerDialog extends DialogFragment {
} }
if (!App.isProVersion()) { if (!App.isProVersion()) {
Toast.makeText(getActivity(), getString(R.string.sleep_timer_is_a_pro_feature), Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), getString(R.string.sleep_timer_is_a_pro_feature), Toast.LENGTH_LONG).show();
BuyDialog.create().show(getFragmentManager(), "BUY_DIALOG"); startActivity(new Intent(getContext(), PurchaseActivity.class));
dismiss();
return; return;
} }

View file

@ -30,7 +30,6 @@ import com.kabouzeid.appthemehelper.util.ATHUtil;
import com.kabouzeid.appthemehelper.util.NavigationViewUtil; import com.kabouzeid.appthemehelper.util.NavigationViewUtil;
import com.kabouzeid.gramophone.App; import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R; import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.dialogs.BuyDialog;
import com.kabouzeid.gramophone.dialogs.ChangelogDialog; import com.kabouzeid.gramophone.dialogs.ChangelogDialog;
import com.kabouzeid.gramophone.glide.SongGlideRequest; import com.kabouzeid.gramophone.glide.SongGlideRequest;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote; import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
@ -57,6 +56,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
public static final String TAG = MainActivity.class.getSimpleName(); public static final String TAG = MainActivity.class.getSimpleName();
public static final int APP_INTRO_REQUEST = 100; public static final int APP_INTRO_REQUEST = 100;
public static final int PURCHASE_REQUEST = 101;
private static final int LIBRARY = 0; private static final int LIBRARY = 0;
private static final int FOLDERS = 1; private static final int FOLDERS = 1;
@ -112,7 +112,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
private void setMusicChooser(int key) { private void setMusicChooser(int key) {
if (!App.isProVersion() && key == FOLDERS) { if (!App.isProVersion() && key == FOLDERS) {
Toast.makeText(this, R.string.folder_view_is_a_pro_feature, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.folder_view_is_a_pro_feature, Toast.LENGTH_LONG).show();
BuyDialog.create().show(getSupportFragmentManager(), "BUY_DIALOG"); startActivityForResult(new Intent(this, PurchaseActivity.class), PURCHASE_REQUEST);
key = LIBRARY; key = LIBRARY;
} }
@ -146,6 +146,12 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
if (!hasPermissions()) { if (!hasPermissions()) {
requestPermissions(); requestPermissions();
} }
} else if (requestCode == PURCHASE_REQUEST) {
if (resultCode == RESULT_OK) {
if (App.isProVersion()) {
setUpPro();
}
}
} }
} }
@ -169,7 +175,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
NavigationViewUtil.setItemTextColors(navigationView, ThemeStore.textColorPrimary(this), accentColor); NavigationViewUtil.setItemTextColors(navigationView, ThemeStore.textColorPrimary(this), accentColor);
if (App.isProVersion()) { if (App.isProVersion()) {
navigationView.getMenu().removeGroup(R.id.navigation_drawer_menu_category_buy_pro); setUpPro();
} }
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override @Override
@ -196,7 +202,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
BuyDialog.create().show(getSupportFragmentManager(), "BUY_DIALOG"); startActivityForResult(new Intent(MainActivity.this, PurchaseActivity.class), PURCHASE_REQUEST);
} }
}, 200); }, 200);
break; break;
@ -222,6 +228,10 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
}); });
} }
private void setUpPro() {
navigationView.getMenu().removeGroup(R.id.navigation_drawer_menu_category_buy_pro);
}
private void setUpDrawerLayout() { private void setUpDrawerLayout() {
setUpNavigationView(); setUpNavigationView();
} }

View file

@ -0,0 +1,172 @@
package com.kabouzeid.gramophone.ui.activities;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.anjlab.android.iab.v3.BillingProcessor;
import com.anjlab.android.iab.v3.TransactionDetails;
import com.kabouzeid.appthemehelper.color.MaterialColor;
import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
import java.lang.ref.WeakReference;
import butterknife.BindView;
import butterknife.ButterKnife;
public class PurchaseActivity extends AbsBaseActivity implements BillingProcessor.IBillingHandler {
public static final String TAG = PurchaseActivity.class.getSimpleName();
private static final int ACTIVITY_COLOR = MaterialColor.Green._500.getAsColor();
@BindView(R.id.toolbar)
Toolbar toolbar;
@BindView(R.id.restore_button)
Button restoreButton;
@BindView(R.id.purchase_button)
Button purchaseButton;
private BillingProcessor billingProcessor;
private AsyncTask restorePurchaseAsyncTask;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_purchase);
setDrawUnderStatusbar(true);
ButterKnife.bind(this);
setStatusbarColor(ACTIVITY_COLOR);
setNavigationbarColor(ACTIVITY_COLOR);
setTaskDescriptionColor(ACTIVITY_COLOR);
setSupportActionBar(toolbar);
//noinspection ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(getString(R.string.purchase) + " Phonograph Pro");
restoreButton.setEnabled(false);
purchaseButton.setEnabled(false);
restoreButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (restorePurchaseAsyncTask == null || restorePurchaseAsyncTask.getStatus() != AsyncTask.Status.RUNNING) {
restorePurchase();
}
}
});
purchaseButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
billingProcessor.purchase(PurchaseActivity.this, App.PRO_VERSION_PRODUCT_ID);
}
});
billingProcessor = new BillingProcessor(this, App.GOOGLE_PLAY_LICENSE_KEY, this);
}
private void restorePurchase() {
if (restorePurchaseAsyncTask != null) {
restorePurchaseAsyncTask.cancel(false);
}
restorePurchaseAsyncTask = new RestorePurchaseAsyncTask(this).execute();
}
@Override
public void onProductPurchased(@NonNull String productId, @Nullable TransactionDetails details) {
Toast.makeText(this, R.string.thank_you, Toast.LENGTH_SHORT).show();
setResult(RESULT_OK);
}
@Override
public void onPurchaseHistoryRestored() {
if (App.isProVersion()) {
Toast.makeText(this, R.string.restored_previous_purchase_please_restart, Toast.LENGTH_LONG).show();
setResult(RESULT_OK);
} else {
Toast.makeText(this, R.string.no_purchase_found, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onBillingError(int errorCode, @Nullable Throwable error) {
Log.e(TAG, "Billing error: code = " + errorCode, error);
}
@Override
public void onBillingInitialized() {
restoreButton.setEnabled(true);
purchaseButton.setEnabled(true);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (!billingProcessor.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
public void onDestroy() {
if (billingProcessor != null) {
billingProcessor.release();
}
super.onDestroy();
}
private static class RestorePurchaseAsyncTask extends AsyncTask<Void, Void, Boolean> {
private final WeakReference<PurchaseActivity> buyActivityWeakReference;
public RestorePurchaseAsyncTask(PurchaseActivity purchaseActivity) {
this.buyActivityWeakReference = new WeakReference<>(purchaseActivity);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
PurchaseActivity purchaseActivity = buyActivityWeakReference.get();
if (purchaseActivity != null) {
Toast.makeText(purchaseActivity, R.string.restoring_purchase, Toast.LENGTH_SHORT).show();
} else {
cancel(false);
}
}
@Override
protected Boolean doInBackground(Void... params) {
PurchaseActivity purchaseActivity = buyActivityWeakReference.get();
if (purchaseActivity != null) {
return purchaseActivity.billingProcessor.loadOwnedPurchasesFromGoogle();
}
cancel(false);
return null;
}
@Override
protected void onPostExecute(Boolean b) {
super.onPostExecute(b);
PurchaseActivity purchaseActivity = buyActivityWeakReference.get();
if (purchaseActivity == null || b == null) return;
if (b) {
purchaseActivity.onPurchaseHistoryRestored();
} else {
Toast.makeText(purchaseActivity, R.string.could_not_restore_purchase, Toast.LENGTH_SHORT).show();
}
}
}
}

View file

@ -28,12 +28,9 @@ import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.kabouzeid.gramophone.App; import com.kabouzeid.gramophone.App;
import com.kabouzeid.gramophone.R; import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager; import com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager;
import com.kabouzeid.gramophone.dialogs.BuyDialog;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.misc.NonProAllowedColors; import com.kabouzeid.gramophone.misc.NonProAllowedColors;
import com.kabouzeid.gramophone.preferences.NowPlayingScreenPreference; import com.kabouzeid.gramophone.preferences.NowPlayingScreenPreference;
import com.kabouzeid.gramophone.preferences.NowPlayingScreenPreferenceDialog; import com.kabouzeid.gramophone.preferences.NowPlayingScreenPreferenceDialog;
import com.kabouzeid.gramophone.service.MusicService;
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity; import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
import com.kabouzeid.gramophone.util.NavigationUtil; import com.kabouzeid.gramophone.util.NavigationUtil;
import com.kabouzeid.gramophone.util.PreferenceUtil; import com.kabouzeid.gramophone.util.PreferenceUtil;
@ -82,7 +79,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
if (Arrays.binarySearch(NonProAllowedColors.PRIMARY_COLORS, selectedColor) < 0) { if (Arrays.binarySearch(NonProAllowedColors.PRIMARY_COLORS, selectedColor) < 0) {
// color wasn't found // color wasn't found
Toast.makeText(this, R.string.only_the_first_5_colors_available, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.only_the_first_5_colors_available, Toast.LENGTH_LONG).show();
BuyDialog.create().show(getSupportFragmentManager(), "BUY_DIALOG"); startActivity(new Intent(this, PurchaseActivity.class));
return; return;
} }
} }
@ -96,7 +93,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
if (Arrays.binarySearch(NonProAllowedColors.ACCENT_COLORS, selectedColor) < 0) { if (Arrays.binarySearch(NonProAllowedColors.ACCENT_COLORS, selectedColor) < 0) {
// color wasn't found // color wasn't found
Toast.makeText(this, R.string.only_the_first_5_colors_available, Toast.LENGTH_LONG).show(); Toast.makeText(this, R.string.only_the_first_5_colors_available, Toast.LENGTH_LONG).show();
BuyDialog.create().show(getSupportFragmentManager(), "BUY_DIALOG"); startActivity(new Intent(this, PurchaseActivity.class));
return; return;
} }
} }
@ -202,7 +199,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
String themeName = (String) o; String themeName = (String) o;
if (themeName.equals("black") && !App.isProVersion()) { if (themeName.equals("black") && !App.isProVersion()) {
Toast.makeText(getActivity(), R.string.black_theme_is_a_pro_feature, Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), R.string.black_theme_is_a_pro_feature, Toast.LENGTH_LONG).show();
BuyDialog.create().show(getFragmentManager(), "BUY_DIALOG"); startActivity(new Intent(getContext(), PurchaseActivity.class));
return false; return false;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

View file

@ -1,49 +0,0 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
grid:alignmentMode="alignBounds">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:orientation="vertical"
grid:layout_column="0"
grid:layout_columnWeight="1"
grid:layout_row="0">
<include
layout="@layout/card_about_app"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp" />
<include layout="@layout/card_support_development" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:orientation="vertical"
grid:layout_column="1"
grid:layout_columnWeight="1"
grid:layout_row="0">
<include
layout="@layout/card_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp" />
<include layout="@layout/card_special_thanks" />
</LinearLayout>
</android.support.v7.widget.GridLayout>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".ui.activities.PurchaseActivity">
<include layout="@layout/status_bar" />
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="128dp"
android:layout_below="@+id/status_bar"
android:background="@color/md_green_500"
android:elevation="4dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
style="@style/Toolbar"
android:background="@android:color/transparent" />
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/app_bar"
android:layout_marginTop="-72dp"
android:clipToPadding="false"
android:elevation="8dp"
android:isScrollContainer="true">
<include layout="@layout/activity_purchase_content" />
</ScrollView>
</RelativeLayout>

View file

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/card_on_app_bar_side_padding"
android:paddingLeft="@dimen/card_on_app_bar_side_padding"
android:paddingRight="@dimen/card_on_app_bar_side_padding"
android:paddingTop="8dp"
android:weightSum="1">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:cardBackgroundColor="?cardBackgroundColor"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitStart"
android:src="@drawable/promo_banner16" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:gravity="center_vertical"
android:paddingBottom="16dp"
android:paddingTop="24dp"
android:text="Phonograph Pro"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="Unlocks extra features, such as the folder view, all theme colors, a black theme and the sleep timer.\n\nThe source code of Phonograph is available on GitHub. You are welcome to compile the pro version yourself for free. However, if you want to support the development and receive updates through the Play Store, consider purchasing Phonograph Pro.\nThank you,\nKarim"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<Button
android:id="@+id/restore_button"
style="@style/Base.Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/restore" />
<Button
android:id="@+id/purchase_button"
style="@style/Base.Widget.AppCompat.Button.Borderless.Colored"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="@string/purchase"
android:textColor="@color/md_green_600" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>

View file

@ -2,4 +2,7 @@
<dimen name="title_view_height">56dp</dimen> <dimen name="title_view_height">56dp</dimen>
<dimen name="header_image_height">180dp</dimen> <dimen name="header_image_height">180dp</dimen>
<dimen name="card_on_app_bar_side_padding">72dp</dimen>
</resources> </resources>

View file

@ -58,4 +58,6 @@ http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout
<dimen name="app_widget_card_buttons_width">128dp</dimen> <dimen name="app_widget_card_buttons_width">128dp</dimen>
<dimen name="app_widget_card_radius">2dp</dimen> <dimen name="app_widget_card_radius">2dp</dimen>
<dimen name="card_on_app_bar_side_padding">8dp</dimen>
</resources> </resources>

View file

@ -197,7 +197,7 @@
<string name="support_development">Support development</string> <string name="support_development">Support development</string>
<string name="buy_pro">Buy Phonograph Pro</string> <string name="buy_pro">Buy Phonograph Pro</string>
<string name="thank_you">Thank you!</string> <string name="thank_you">Thank you!</string>
<string name="restored_previous_purchases_please_restart">Restored previous purchases. Please restart the app to make use of all features.</string> <string name="restored_previous_purchase_please_restart">Restored previous purchase. Please restart the app to make use of all features.</string>
<string name="version">Version</string> <string name="version">Version</string>
<string name="author">Author</string> <string name="author">Author</string>
<string name="write_an_email">Write an email</string> <string name="write_an_email">Write an email</string>
@ -279,4 +279,10 @@
<string name="black_theme_is_a_pro_feature">The black theme is Phonograph Pro feature.</string> <string name="black_theme_is_a_pro_feature">The black theme is Phonograph Pro feature.</string>
<string name="sleep_timer_is_a_pro_feature">Sleep timer is a Phonograph Pro feature</string> <string name="sleep_timer_is_a_pro_feature">Sleep timer is a Phonograph Pro feature</string>
<string name="folder_view_is_a_pro_feature">Folder view is a Phonograph Pro feature.</string> <string name="folder_view_is_a_pro_feature">Folder view is a Phonograph Pro feature.</string>
<string name="restore_purchase">Restore purchase</string>
<string name="restoring_purchase">Restoring purchase…</string>
<string name="could_not_restore_purchase">Could not restore purchase.</string>
<string name="purchase">Purchase</string>
<string name="restore">Restore</string>
<string name="no_purchase_found">No purchase found.</string>
</resources> </resources>