2018-08-26 06:11:06 +00:00
|
|
|
package eu.faircode.email;
|
|
|
|
|
|
|
|
/*
|
|
|
|
This file is part of FairEmail.
|
|
|
|
|
|
|
|
FairEmail is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
2018-10-29 10:46:49 +00:00
|
|
|
FairEmail is distributed in the hope that it will be useful,
|
2018-08-26 06:11:06 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2018-10-29 10:46:49 +00:00
|
|
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-26 06:11:06 +00:00
|
|
|
|
2018-12-31 08:04:33 +00:00
|
|
|
Copyright 2018-2019 by Marcel Bokhorst (M66B)
|
2018-08-26 06:11:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.preference.PreferenceManager;
|
|
|
|
import android.text.Html;
|
|
|
|
import android.text.method.LinkMovementMethod;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
2019-01-15 17:41:55 +00:00
|
|
|
public class FragmentPro extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
2018-08-26 06:11:06 +00:00
|
|
|
private TextView tvActivated;
|
|
|
|
private TextView tvList;
|
|
|
|
private Button btnPurchase;
|
2018-09-13 07:15:56 +00:00
|
|
|
private TextView tvPrice;
|
2018-08-26 06:11:06 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
@Nullable
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
setSubtitle(R.string.menu_pro);
|
|
|
|
|
|
|
|
View view = inflater.inflate(R.layout.fragment_pro, container, false);
|
|
|
|
|
|
|
|
tvActivated = view.findViewById(R.id.tvActivated);
|
|
|
|
tvList = view.findViewById(R.id.tvList);
|
|
|
|
btnPurchase = view.findViewById(R.id.btnPurchase);
|
2018-09-13 07:15:56 +00:00
|
|
|
tvPrice = view.findViewById(R.id.tvPrice);
|
2018-08-26 06:11:06 +00:00
|
|
|
|
2019-02-10 12:01:21 +00:00
|
|
|
tvList.setText(HtmlHelper.fromHtml(
|
|
|
|
"<a href=\"" + BuildConfig.PRO_FEATURES_URI + "\">" + Html.escapeHtml(getString(R.string.title_pro_list)) + "</a>"));
|
2018-08-26 06:11:06 +00:00
|
|
|
tvList.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
|
|
|
|
|
btnPurchase.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
|
|
|
lbm.sendBroadcast(new Intent(ActivityView.ACTION_PURCHASE));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-09-13 07:15:56 +00:00
|
|
|
tvPrice.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
|
|
2018-08-26 06:11:06 +00:00
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
2018-12-16 14:22:55 +00:00
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
onSharedPreferenceChanged(prefs, "pro");
|
|
|
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
2018-08-26 06:11:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPause() {
|
|
|
|
super.onPause();
|
2018-12-16 14:22:55 +00:00
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
prefs.unregisterOnSharedPreferenceChangeListener(this);
|
2018-08-26 06:11:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
|
|
|
if ("pro".equals(key)) {
|
|
|
|
boolean pro = prefs.getBoolean(key, false);
|
|
|
|
tvActivated.setVisibility(pro ? View.VISIBLE : View.GONE);
|
2019-01-12 16:17:50 +00:00
|
|
|
btnPurchase.setEnabled(BuildConfig.DEBUG || !pro);
|
2018-08-26 06:11:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|