this commit fixed #607

It also adds Amlod theme as in app purchase, those who has supported FastHub before will be getting it for Free however the rest will have to either support development or purchase the theme, this commit also shows a heart badge indicates that the user has supportedDevelopment before.
This commit is contained in:
Kosh 2017-06-10 14:12:29 +08:00
parent 30d849e27e
commit dec95bf5f7
20 changed files with 297 additions and 207 deletions

View File

@ -6,4 +6,5 @@
<string name="donation_product_2" translatable="false">android.test.canceled</string>
<string name="donation_product_3" translatable="false">android.test.refunded</string>
<string name="donation_product_4" translatable="false">android.test.item_unavailable</string>
<string name="amlod_theme_purchase" translatable="false">android.test.purchased</string>
</resources>

View File

@ -185,6 +185,13 @@
android:value=".ui.modules.main.MainActivity"/>
</activity>
<activity android:name=".ui.modules.theme.ThemeActivity"/>
<activity
android:name=".ui.modules.main.donation.DonateActivity"
android:configChanges="keyboard|orientation|screenSize"
android:theme="@style/ThemeTranslucent"/>
<activity
android:name=".ui.modules.parser.LinksParserActivity"
android:configChanges="keyboard|orientation|screenSize"
@ -217,7 +224,6 @@
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity android:name=".ui.modules.theme.ThemeActivity"/>
<service
android:name=".provider.tasks.notification.NotificationSchedulerJobTask"

View File

@ -85,6 +85,8 @@ public class PrefGetter {
private static final String SENT_VIA = "sent_via";
private static final String SENT_VIA_BOX = "sent_via_enabled";
private static final String PROFILE_BACKGROUND_URL = "profile_background_url";
private static final String AMLOD_THEME_ENABLED = "amlod_theme_enabled";
private static final String PRO_ITEMS = "pro_items";
public static void setToken(@NonNull String token) {
PrefHelper.set(TOKEN, token);
@ -319,4 +321,21 @@ public class PrefGetter {
public static boolean isNotificationSoundEnabled() {
return PrefHelper.getBoolean("notificationSound");
}
public static void enableAmlodTheme() {
PrefHelper.set(AMLOD_THEME_ENABLED, true);
}
public static boolean isAmlodEnabled() {
return PrefHelper.getBoolean(AMLOD_THEME_ENABLED);
}
public static void setProItems() {
PrefHelper.set(PRO_ITEMS, true);
enableAmlodTheme();
}
public static boolean isProEnabled() {
return PrefHelper.getBoolean(PRO_ITEMS);
}
}

View File

@ -452,7 +452,8 @@ public abstract class BaseActivity<V extends BaseMvp.FAView, P extends BasePrese
view.findViewById(R.id.email).setVisibility(View.GONE);
}
view.findViewById(R.id.userHolder).setOnClickListener(v -> UserPagerActivity.startActivity(this, userModel.getLogin()));
view.findViewById(R.id.donatedIcon).setVisibility(PrefGetter.isProEnabled() || PrefGetter.isAmlodEnabled()
? View.VISIBLE : View.GONE);
}
}
}

View File

@ -15,6 +15,7 @@ import android.view.View;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import com.evernote.android.state.State;
import com.fastaccess.BuildConfig;
import com.fastaccess.R;
import com.fastaccess.data.dao.model.Login;
@ -24,10 +25,15 @@ import com.fastaccess.helper.AppHelper;
import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.Bundler;
import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.Logger;
import com.fastaccess.helper.PrefGetter;
import com.fastaccess.helper.PrefHelper;
import com.fastaccess.ui.base.BaseActivity;
import com.fastaccess.ui.modules.main.MainActivity;
import com.fastaccess.ui.modules.settings.LanguageBottomSheetDialog;
import com.miguelbcr.io.rx_billing_service.RxBillingService;
import com.miguelbcr.io.rx_billing_service.entities.ProductType;
import com.miguelbcr.io.rx_billing_service.entities.Purchase;
import java.util.Arrays;
import java.util.Locale;
@ -37,7 +43,7 @@ import butterknife.OnClick;
import butterknife.OnEditorAction;
import butterknife.Optional;
import es.dmoral.toasty.Toasty;
import com.evernote.android.state.State;
import io.reactivex.functions.Action;
/**
* Created by Kosh on 08 Feb 2017, 9:10 PM
@ -54,11 +60,6 @@ public class LoginActivity extends BaseActivity<LoginMvp.View, LoginPresenter> i
@Nullable @BindView(R.id.twoFactorEditText) TextInputEditText twoFactorEditText;
@Nullable @BindView(R.id.login) FloatingActionButton login;
@Nullable @BindView(R.id.progress) ProgressBar progress;
// private String pass;
// private static int RESOLUTION_CODE = 100;
// private static int RESOLUTION_CHOOSER_CODE = 101;
@State boolean isBasicAuth;
public static void start(@NonNull Activity activity, boolean isBasicAuth) {
@ -138,46 +139,18 @@ public class LoginActivity extends BaseActivity<LoginMvp.View, LoginPresenter> i
}
@Override public void onSuccessfullyLoggedIn() {
hideProgress();
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finishAffinity();
checkPurchases(() -> {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finishAffinity();
});
}
@Override public void onSuccessfullyLoggedIn(Login userModel) {
// Credential credential = new Credential.Builder(userModel.getLogin())
// .setPassword(pass)
// .setProfilePictureUri(Uri.parse(userModel.getAvatarUrl()))
// .build();
// Auth.CredentialsApi.save(App.getInstance().getGoogleApiClient(), credential).setResultCallback(status -> {
// if (status.isSuccess()) {
// onSuccessfullyLoggedIn();
// } else if (status.hasResolution()) {
// try {
// status.startResolutionForResult(this, RESOLUTION_CODE);
// } catch (IntentSender.SendIntentException e) {
// e.printStackTrace();
// }
// } else {
// Log.e(getLoggingTag(), status + "");
// onSuccessfullyLoggedIn();
// }
// });
onSuccessfullyLoggedIn();
}
// @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if (requestCode == RESOLUTION_CODE) {
// onSuccessfullyLoggedIn();
// } else if (requestCode == RESOLUTION_CHOOSER_CODE) {
// if (resultCode == RESULT_OK) {
// Credential credential = data.getParcelableExtra(Credential.EXTRA_KEY);
// doLogin(credential.getId(), credential.getPassword());
// }
// }
// }
@Override protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.LoginTheme);
super.onCreate(savedInstanceState);
@ -186,14 +159,6 @@ public class LoginActivity extends BaseActivity<LoginMvp.View, LoginPresenter> i
isBasicAuth = getIntent().getExtras().getBoolean(BundleConstant.YES_NO_EXTRA);
}
}
// if (username != null)
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.) {
// username.setAutofillHints(View.AUTOFILL_HINT_USERNAME);
// }
// if (password != null) {
// password.setHint(isBasicAuth ? getString(R.string.password) : getString(R.string.access_token));
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) password.setAutofillHints(View.AUTOFILL_HINT_PASSWORD);
// }
if (Arrays.asList(getResources().getStringArray(R.array.languages_array_values)).contains(Locale.getDefault().getLanguage())) {
String language = PrefHelper.getString("app_language");
PrefHelper.set("app_language", Locale.getDefault().getLanguage());
@ -201,23 +166,6 @@ public class LoginActivity extends BaseActivity<LoginMvp.View, LoginPresenter> i
if (!Locale.getDefault().getLanguage().equals(language)) recreate();
}
// if (isBasicAuth && getIntent() != null)
// if (getIntent().hasExtra("smartLock"))
// if (App.getInstance().getGoogleApiClient().isConnecting() &&
// !App.getInstance().getGoogleApiClient().isConnected()) {
// App.getInstance().getGoogleApiClient().registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
// @Override
// public void onConnected(@Nullable Bundle bundle) {
// doCredentialRequest();
// }
//
// @Override
// public void onConnectionSuspended(int i) {
// }
// });
// } else {
// doCredentialRequest();
// }
}
@Override protected void onNewIntent(Intent intent) {
@ -268,25 +216,33 @@ public class LoginActivity extends BaseActivity<LoginMvp.View, LoginPresenter> i
login.show();
}
// private void doCredentialRequest() {
// CredentialRequest credentialRequest = new CredentialRequest.Builder()
// .setPasswordLoginSupported(true)
// .build();
// Auth.CredentialsApi.request(App.getInstance().getGoogleApiClient(), credentialRequest).setResultCallback(credentialRequestResult -> {
// if (credentialRequestResult.getStatus().isSuccess()) {
// doLogin(credentialRequestResult.getCredential().getId(),
// credentialRequestResult.getCredential().getPassword());
// } else if (credentialRequestResult.getStatus().hasResolution())
// try {
// credentialRequestResult.getStatus().startResolutionForResult(this, RESOLUTION_CHOOSER_CODE);
// } catch (IntentSender.SendIntentException e) {
// e.printStackTrace();
// }
// else {
// Log.e(getLoggingTag(), credentialRequestResult.getStatus() + "");
// }
// });
// }
protected void checkPurchases(Action action) {
RxBillingService.getInstance(this, BuildConfig.DEBUG)
.getPurchases(ProductType.IN_APP)
.doOnSubscribe(disposable -> showProgress(0))
.subscribe((purchases, throwable) -> {
hideProgress();
if (throwable == null) {
Logger.e(purchases);
if (purchases != null && !purchases.isEmpty()) {
for (Purchase purchase : purchases) {
String sku = purchase.sku();
if (sku != null) {
Logger.e(sku);
if (sku.equalsIgnoreCase(getString(R.string.donation_product_1))) {
PrefGetter.enableAmlodTheme();
} else {
PrefGetter.setProItems();
}
}
}
}
} else {
throwable.printStackTrace();
}
action.run();
});
}
private void showLanguage() {
LanguageBottomSheetDialog languageBottomSheetDialog = new LanguageBottomSheetDialog();
@ -303,11 +259,4 @@ public class LoginActivity extends BaseActivity<LoginMvp.View, LoginPresenter> i
isBasicAuth, false);
}
}
// private void doLogin(String username, String password) {
// if (progress == null || twoFactor == null || username == null || password == null) return;
// if (progress.getVisibility() == View.GONE) {
// getPresenter().login(username, password, "", isBasicAuth, true);
// }
// }
}

View File

@ -0,0 +1,102 @@
package com.fastaccess.ui.modules.main.donation
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.support.v4.app.Fragment
import com.crashlytics.android.answers.Answers
import com.crashlytics.android.answers.PurchaseEvent
import com.fastaccess.BuildConfig
import com.fastaccess.R
import com.fastaccess.helper.*
import com.fastaccess.ui.base.BaseActivity
import com.fastaccess.ui.base.mvp.BaseMvp
import com.fastaccess.ui.base.mvp.presenter.BasePresenter
import com.miguelbcr.io.rx_billing_service.RxBillingService
import com.miguelbcr.io.rx_billing_service.RxBillingServiceException
import com.miguelbcr.io.rx_billing_service.entities.ProductType
import com.miguelbcr.io.rx_billing_service.entities.Purchase
import io.reactivex.disposables.Disposable
/**
* Created by Kosh on 10 Jun 2017, 1:04 PM
*/
class DonateActivity : BaseActivity<BaseMvp.FAView, BasePresenter<BaseMvp.FAView>>() {
private var subscription: Disposable? = null
override fun layout(): Int {
return 0
}
override fun isTransparent(): Boolean {
return false
}
override fun canBack(): Boolean {
return false
}
override fun isSecured(): Boolean {
return false
}
override fun providePresenter(): BasePresenter<BaseMvp.FAView> {
return BasePresenter()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val bundle: Bundle = intent.extras
val productKey: String = bundle.getString(BundleConstant.EXTRA)
subscription = RxHelper.getSingle<Purchase>(RxBillingService.getInstance(this, BuildConfig.DEBUG)
.purchase(ProductType.IN_APP, productKey, "inapp:com.fastaccess.github:" + productKey))
.subscribe { _, throwable ->
if (throwable == null) {
Answers.getInstance().logPurchase(PurchaseEvent().putItemName(productKey))
showMessage(R.string.success, R.string.success_purchase_message)
if (productKey == getString(R.string.donation_product_1)) {
PrefGetter.enableAmlodTheme()
} else {
PrefGetter.setProItems()
}
setResult(Activity.RESULT_OK)
} else {
if (throwable is RxBillingServiceException) {
val code = throwable.code
showErrorMessage(throwable.message!!)
Logger.e(code)
setResult(Activity.RESULT_CANCELED)
}
throwable.printStackTrace()
}
finish()
}
}
override fun onDestroy() {
if (subscription != null && !subscription?.isDisposed!!) {
subscription?.dispose()
}
super.onDestroy()
}
companion object {
fun start(context: Activity, product: String?) {
val intent = Intent(context, DonateActivity::class.java)
intent.putExtras(Bundler.start()
.put(BundleConstant.EXTRA, product)
.end())
context.startActivityForResult(intent, BundleConstant.REQUEST_CODE)
}
fun start(context: Fragment, product: String?) {
val intent = Intent(context.context, DonateActivity::class.java)
intent.putExtras(Bundler.start()
.put(BundleConstant.EXTRA, product)
.end())
context.startActivityForResult(intent, BundleConstant.REQUEST_CODE)
}
}
}

View File

@ -1,29 +1,19 @@
package com.fastaccess.ui.modules.main.donation;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.AppBarLayout;
import android.view.View;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.PurchaseEvent;
import com.fastaccess.BuildConfig;
import com.fastaccess.R;
import com.fastaccess.helper.AnimHelper;
import com.fastaccess.helper.Logger;
import com.fastaccess.helper.RxHelper;
import com.fastaccess.ui.base.BaseActivity;
import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
import com.miguelbcr.io.rx_billing_service.RxBillingService;
import com.miguelbcr.io.rx_billing_service.RxBillingServiceException;
import com.miguelbcr.io.rx_billing_service.entities.ProductType;
import net.grandcentrix.thirtyinch.TiPresenter;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.disposables.Disposable;
/**
* Created by Kosh on 24 Mar 2017, 9:16 PM
@ -32,14 +22,7 @@ import io.reactivex.disposables.Disposable;
public class DonationActivity extends BaseActivity {
@BindView(R.id.cardsHolder) View cardsHolder;
@BindView(R.id.appbar) AppBarLayout appBarLayout;
private Disposable subscription;
@Override protected void onDestroy() {
if (subscription != null && !subscription.isDisposed()) {
subscription.dispose();
}
super.onDestroy();
}
@Override protected int layout() {
return R.layout.support_development_layout;
@ -62,23 +45,19 @@ public class DonationActivity extends BaseActivity {
AnimHelper.animateVisibility(cardsHolder, true);
}
@Override protected void onStop() {
super.onStop();
}
@OnClick(R.id.two) public void onTwoClicked() {
@OnClick(R.id.two) public void onTwoClicked(View v) {
onProceed(getString(R.string.donation_product_1));
}
@OnClick(R.id.five) public void onFiveClicked() {
@OnClick(R.id.five) public void onFiveClicked(View v) {
onProceed(getString(R.string.donation_product_2));
}
@OnClick(R.id.ten) public void onTenClicked() {
@OnClick(R.id.ten) public void onTenClicked(View v) {
onProceed(getString(R.string.donation_product_3));
}
@OnClick(R.id.twenty) public void onTwentyClicked() {
@OnClick(R.id.twenty) public void onTwentyClicked(View v) {
onProceed(getString(R.string.donation_product_4));
}
@ -87,23 +66,7 @@ public class DonationActivity extends BaseActivity {
}
private void onProceed(@NonNull String productKey) {
// RxBillingService.getInstance(this, BuildConfig.DEBUG)
// .getPurchases(ProductType.IN_APP)
// .subscribe((purchases, throwable) -> Logger.e(purchases));
subscription = RxHelper.getSingle(RxBillingService.getInstance(this, BuildConfig.DEBUG)
.purchase(ProductType.IN_APP, productKey, "inapp:com.fastaccess.github:" + productKey))
.doOnSubscribe(disposable -> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT))
.doFinally(() -> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER))
.subscribe((purchase, throwable) -> {
if (throwable == null) {
Answers.getInstance().logPurchase(new PurchaseEvent().putItemName(productKey));
showMessage(R.string.success, R.string.success_purchase_message);
} else {
if (throwable instanceof RxBillingServiceException) {
Logger.e(((RxBillingServiceException) throwable).getCode());
}
throwable.printStackTrace();
}
});
DonateActivity.Companion.start(this, productKey);
}
}

View File

@ -48,7 +48,9 @@ public class SettingsActivity extends BaseActivity {
super.onCreate(savedInstanceState);
setToolbarIcon(R.drawable.ic_back);
setTitle(getString(R.string.settings));
setResult(RESULT_CANCELED);
if (savedInstanceState == null) {
setResult(RESULT_CANCELED);
}
settings = new SettingsModel[]{
SettingsModel.newInstance(R.drawable.ic_ring, getString(R.string.notifications), ""),
SettingsModel.newInstance(R.drawable.ic_settings, getString(R.string.behavior), ""),
@ -68,7 +70,7 @@ public class SettingsActivity extends BaseActivity {
if (settingsModel.getTitle().equalsIgnoreCase(getString(R.string.app_language))) {
showLanguageList();
} else if (settingsModel.getTitle().equalsIgnoreCase(getString(R.string.theme_title))) {
ActivityHelper.startReveal(this, new Intent(this, ThemeActivity.class), view);
ActivityHelper.startReveal(this, new Intent(this, ThemeActivity.class), view, THEME_CHANGE);
} else {
ActivityHelper.startReveal(this, intent, view);
}
@ -76,8 +78,10 @@ public class SettingsActivity extends BaseActivity {
}
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == THEME_CHANGE)
if (requestCode == THEME_CHANGE) {
setResult(resultCode);
finish();
}
}
@NonNull @Override public TiPresenter providePresenter() {

View File

@ -50,7 +50,6 @@ public class SettingsCategoryFragment extends PreferenceFragmentCompat implement
private static int RESTORE_REQUEST_CODE = 256;
private BaseMvp.FAView callback;
private String appTheme;
private String appColor;
private String app_lauguage;
@ -64,7 +63,6 @@ public class SettingsCategoryFragment extends PreferenceFragmentCompat implement
super.onAttach(context);
this.callback = (BaseMvp.FAView) context;
this.settingsCallback = (SettingsCallback) context;
appTheme = PrefHelper.getString("appTheme");
appColor = PrefHelper.getString("appColor");
app_lauguage = PrefHelper.getString("app_language");
}
@ -107,7 +105,6 @@ public class SettingsCategoryFragment extends PreferenceFragmentCompat implement
findPreference("enable_ads").setVisible(false);
findPreference("recylerViewAnimation").setOnPreferenceChangeListener(this);
findPreference("rect_avatar").setOnPreferenceChangeListener(this);
findPreference("appTheme").setOnPreferenceChangeListener(this);
findPreference("appColor").setOnPreferenceChangeListener(this);
break;
case 3:
@ -188,12 +185,6 @@ public class SettingsCategoryFragment extends PreferenceFragmentCompat implement
} else if (preference.getKey().equalsIgnoreCase("rect_avatar")) {
callback.onThemeChanged();
return true;
} else if (preference.getKey().equalsIgnoreCase("appTheme")) {
if (newValue.toString().equalsIgnoreCase(appTheme))
return true;
Toasty.warning(getContext(), getString(R.string.change_theme_warning), Toast.LENGTH_LONG).show();
callback.onThemeChanged();
return true;
} else if (preference.getKey().equalsIgnoreCase("appColor")) {
if (newValue.toString().equalsIgnoreCase(appColor))
return true;

View File

@ -1,5 +1,6 @@
package com.fastaccess.ui.modules.theme
import android.app.Activity
import android.os.Build
import android.os.Bundle
import android.support.design.widget.TabLayout
@ -59,4 +60,10 @@ class ThemeActivity : BaseActivity<BaseMvp.FAView, BasePresenter<BaseMvp.FAView>
pager.systemUiVisibility = if (darkIcons) View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR else 0
}
}
override fun onThemeApplied() {
setResult(Activity.RESULT_OK)
showMessage(R.string.success, R.string.change_theme_warning)
finish()
}
}

View File

@ -1,18 +1,21 @@
package com.fastaccess.ui.modules.theme.fragment
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.support.design.widget.FloatingActionButton
import android.support.v7.widget.Toolbar
import android.view.ContextThemeWrapper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.fastaccess.R
import com.fastaccess.helper.BundleConstant
import com.fastaccess.helper.Bundler
import com.fastaccess.helper.PrefHelper
import com.fastaccess.helper.ViewHelper
import com.fastaccess.helper.*
import com.fastaccess.ui.base.BaseFragment
import com.fastaccess.ui.modules.main.donation.DonateActivity
import com.fastaccess.ui.widgets.SpannableBuilder
/**
* Created by Kosh on 08 Jun 2017, 10:53 PM
@ -21,6 +24,7 @@ import com.fastaccess.ui.base.BaseFragment
class ThemeFragment : BaseFragment<ThemeFragmentMvp.View, ThemeFragmentPresenter>(), ThemeFragmentMvp.View {
val apply: FloatingActionButton by lazy { view!!.findViewById<FloatingActionButton>(R.id.apply) }
val toolbar: Toolbar by lazy { view!!.findViewById<Toolbar>(R.id.toolbar) }
private var primaryDarkColor: Int = 0
private var theme: Int = 0
@ -41,9 +45,32 @@ class ThemeFragment : BaseFragment<ThemeFragmentMvp.View, ThemeFragmentPresenter
}
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
apply.setOnClickListener { PrefHelper.set("appTheme", getString(R.string.amlod_theme_mode)) }
apply.setOnClickListener {
when (theme) {
R.style.ThemeLight -> {
PrefHelper.set("appTheme", getString(R.string.light_theme_mode))
themeListener?.onThemeApplied()
}
R.style.ThemeDark -> {
PrefHelper.set("appTheme", getString(R.string.dark_theme_mode))
themeListener?.onThemeApplied()
}
else -> if (PrefGetter.isAmlodEnabled() || PrefGetter.isProEnabled()) {
PrefHelper.set("appTheme", getString(R.string.amlod_theme_mode))
themeListener?.onThemeApplied()
} else {
DonateActivity.Companion.start(this, getString(R.string.amlod_theme_purchase))
}
}
}
if (isPremiumTheme()) {
toolbar.title = SpannableBuilder.builder().foreground(getString(R.string.premium_theme), Color.RED)
}
toolbar.setNavigationOnClickListener { activity.onBackPressed() }
}
private fun isPremiumTheme(): Boolean = theme == R.style.ThemeAmlod
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
super.onCreateView(inflater, container, savedInstanceState)
theme = arguments.getInt(BundleConstant.ITEM)
@ -67,6 +94,15 @@ class ThemeFragment : BaseFragment<ThemeFragmentMvp.View, ThemeFragmentPresenter
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK) {
if (PrefGetter.isProEnabled() || PrefGetter.isAmlodEnabled()) {
themeListener?.onThemeApplied()
}
}
}
companion object {
fun newInstance(style: Int): ThemeFragment {
val fragment = ThemeFragment()

View File

@ -1,20 +0,0 @@
package com.fastaccess.ui.modules.theme.fragment;
import android.support.annotation.ColorInt;
import com.fastaccess.ui.base.mvp.BaseMvp;
/**
* Created by Kosh on 08 Jun 2017, 10:52 PM
*/
public interface ThemeFragmentMvp {
interface ThemeListener {
void onChangePrimaryDarkColor(@ColorInt int color, boolean darkIcons);
}
interface View extends BaseMvp.FAView {}
interface Presenter {}
}

View File

@ -0,0 +1,22 @@
package com.fastaccess.ui.modules.theme.fragment
import android.support.annotation.ColorInt
import com.fastaccess.ui.base.mvp.BaseMvp
/**
* Created by Kosh on 08 Jun 2017, 10:52 PM
*/
interface ThemeFragmentMvp {
interface ThemeListener {
fun onChangePrimaryDarkColor(@ColorInt color: Int, darkIcons: Boolean)
fun onThemeApplied()
}
interface View : BaseMvp.FAView
interface Presenter
}

View File

@ -1,9 +0,0 @@
package com.fastaccess.ui.modules.theme.fragment;
import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
/**
* Created by Kosh on 08 Jun 2017, 10:52 PM
*/
public class ThemeFragmentPresenter extends BasePresenter<ThemeFragmentMvp.View> implements ThemeFragmentMvp.Presenter {}

View File

@ -0,0 +1,9 @@
package com.fastaccess.ui.modules.theme.fragment
import com.fastaccess.ui.base.mvp.presenter.BasePresenter
/**
* Created by Kosh on 08 Jun 2017, 10:52 PM
*/
class ThemeFragmentPresenter : BasePresenter<ThemeFragmentMvp.View>(), ThemeFragmentMvp.Presenter

View File

@ -6,8 +6,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:windowBackground"
app:statusBarBackground="?colorPrimaryDark">
android:background="?android:windowBackground">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
@ -19,8 +18,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorPrimary"
android:clipChildren="false"
android:clipToPadding="false"
android:minHeight="?actionBarSize"
android:orientation="horizontal"
android:paddingBottom="@dimen/spacing_normal"
@ -43,6 +40,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
@ -154,7 +152,7 @@
android:maxLines="3"
android:textColor="?android:textColorPrimary"
android:transitionName="@string/title_transition"
tools:text="Comrades wave from fortunes like wet biscuit eaters."/>
android:text="Comrades wave from fortunes like wet biscuit eaters."/>
<com.fastaccess.ui.widgets.FontTextView
style="@style/TextAppearance.AppCompat.Small"
@ -205,7 +203,7 @@
android:maxLines="3"
android:textColor="?android:textColorPrimary"
android:transitionName="@string/title_transition"
tools:text="Comrades wave from fortunes like wet biscuit eaters."/>
android:text="Comrades wave from fortunes like wet biscuit eaters."/>
<com.fastaccess.ui.widgets.FontTextView
style="@style/TextAppearance.AppCompat.Small"
@ -256,7 +254,7 @@
android:maxLines="3"
android:textColor="?android:textColorPrimary"
android:transitionName="@string/title_transition"
tools:text="Comrades wave from fortunes like wet biscuit eaters."/>
android:text="Comrades wave from fortunes like wet biscuit eaters."/>
<com.fastaccess.ui.widgets.FontTextView
style="@style/TextAppearance.AppCompat.Small"
@ -307,7 +305,7 @@
android:maxLines="3"
android:textColor="?android:textColorPrimary"
android:transitionName="@string/title_transition"
tools:text="Comrades wave from fortunes like wet biscuit eaters."/>
android:text="Comrades wave from fortunes like wet biscuit eaters."/>
<com.fastaccess.ui.widgets.FontTextView
style="@style/TextAppearance.AppCompat.Small"
@ -358,7 +356,7 @@
android:maxLines="3"
android:textColor="?android:textColorPrimary"
android:transitionName="@string/title_transition"
tools:text="Comrades wave from fortunes like wet biscuit eaters."/>
android:text="Comrades wave from fortunes like wet biscuit eaters."/>
<com.fastaccess.ui.widgets.FontTextView
style="@style/TextAppearance.AppCompat.Small"

View File

@ -26,33 +26,45 @@
android:layout_marginEnd="@dimen/avatar_margin_end"
android:layout_marginStart="@dimen/avatar_margin"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:orientation="vertical">
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/username"
android:id="@+id/email"
style="@style/TextAppearance.AppCompat.Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="marquee"
android:maxLines="1"
android:singleLine="true"
android:text="@string/app_name"/>
<com.fastaccess.ui.widgets.FontTextView
android:id="@+id/email"
android:id="@+id/username"
style="@style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="marquee"
android:maxLines="1"
android:singleLine="true"
android:text="@string/app_name"
tools:visibility="gone"/>
</LinearLayout>
<com.fastaccess.ui.widgets.ForegroundImageView
android:id="@+id/donatedIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/success_purchase_message"
android:src="@drawable/ic_heart_full"
android:visibility="gone"
tools:visibility="visible"/>
</LinearLayout>
</LinearLayout>

View File

@ -479,4 +479,5 @@
<string name="reviewer_added">Reviewer added successfully</string>
<string name="milestone_added">Milestone added successfully</string>
<string name="feed">Feed</string>
<string name="premium_theme">Premium Theme</string>
</resources>

View File

@ -26,6 +26,14 @@
</style>
<style name="ThemeTranslucent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>
<style name="TextAppearance.Design.CollapsingToolbar.Expanded.LightText" parent="TextAppearance.Design.CollapsingToolbar.Expanded">
<item name="android:textColor">@color/white</item>
</style>

View File

@ -7,16 +7,6 @@
android:key="enable_ads"
android:title="@string/enable_ads"/>
<ListPreference
android:defaultValue="@string/light_theme_mode"
android:dialogTitle="@string/theme_title"
android:entries="@array/theme_modes"
android:entryValues="@array/theme_modes"
android:key="appTheme"
android:icon="@drawable/ic_brush"
android:summary="@string/theme_summary"
android:title="@string/theme_title"/>
<ListPreference
android:defaultValue="@string/blue_theme_mode"
android:dialogTitle="@string/theme_color_title"