mirror of https://github.com/M66B/FairEmail.git
Simplification
This commit is contained in:
parent
8ee2e1ec83
commit
ddbe0dcae3
|
@ -98,7 +98,7 @@ import javax.crypto.SecretKeyFactory;
|
|||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.PBEKeySpec;
|
||||
|
||||
public class ActivitySetup extends ActivityBilling implements FragmentManager.OnBackStackChangedListener {
|
||||
public class ActivitySetup extends ActivityBase implements FragmentManager.OnBackStackChangedListener {
|
||||
private View view;
|
||||
private DrawerLayout drawerLayout;
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
|
@ -121,7 +121,6 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
static final String ACTION_VIEW_IDENTITIES = BuildConfig.APPLICATION_ID + ".ACTION_VIEW_IDENTITIES";
|
||||
static final String ACTION_EDIT_ACCOUNT = BuildConfig.APPLICATION_ID + ".EDIT_ACCOUNT";
|
||||
static final String ACTION_EDIT_IDENTITY = BuildConfig.APPLICATION_ID + ".EDIT_IDENTITY";
|
||||
static final String ACTION_SHOW_PRO = BuildConfig.APPLICATION_ID + ".SHOW_PRO";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -304,7 +303,6 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
iff.addAction(ACTION_VIEW_IDENTITIES);
|
||||
iff.addAction(ACTION_EDIT_ACCOUNT);
|
||||
iff.addAction(ACTION_EDIT_IDENTITY);
|
||||
iff.addAction(ACTION_SHOW_PRO);
|
||||
lbm.registerReceiver(receiver, iff);
|
||||
}
|
||||
|
||||
|
@ -368,17 +366,15 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
}
|
||||
|
||||
private void onMenuExport() {
|
||||
if (!Helper.isPro(this)) {
|
||||
onShowPro(null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
askPassword(true);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
Helper.unexpectedError(getSupportFragmentManager(), ex);
|
||||
}
|
||||
if (Helper.isPro(this)) {
|
||||
try {
|
||||
askPassword(true);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
Helper.unexpectedError(getSupportFragmentManager(), ex);
|
||||
}
|
||||
} else
|
||||
Toast.makeText(this, R.string.title_pro_feature, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void onMenuImport() {
|
||||
|
@ -994,15 +990,6 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
private void onShowPro(Intent intent) {
|
||||
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED))
|
||||
getSupportFragmentManager().popBackStack("pro", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
|
||||
fragmentTransaction.commit();
|
||||
}
|
||||
|
||||
private static Intent getIntentExport() {
|
||||
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
|
@ -1089,8 +1076,6 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
onEditAccount(intent);
|
||||
else if (ACTION_EDIT_IDENTITY.equals(action))
|
||||
onEditIdentity(intent);
|
||||
else if (ACTION_SHOW_PRO.equals(action))
|
||||
onShowPro(intent);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -48,11 +48,11 @@ import android.widget.RadioGroup;
|
|||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
@ -1260,14 +1260,11 @@ public class FragmentAccount extends FragmentBase {
|
|||
switch (requestCode) {
|
||||
case REQUEST_COLOR:
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
if (!Helper.isPro(getContext())) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
|
||||
return;
|
||||
}
|
||||
|
||||
Bundle args = data.getBundleExtra("args");
|
||||
setColor(args.getInt("color"));
|
||||
if (Helper.isPro(getContext())) {
|
||||
Bundle args = data.getBundleExtra("args");
|
||||
setColor(args.getInt("color"));
|
||||
} else
|
||||
Toast.makeText(getContext(), R.string.title_pro_feature, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
break;
|
||||
case REQUEST_SAVE:
|
||||
|
|
|
@ -51,12 +51,12 @@ import android.widget.RadioGroup;
|
|||
import android.widget.ScrollView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.constraintlayout.widget.Group;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
@ -1000,14 +1000,11 @@ public class FragmentIdentity extends FragmentBase {
|
|||
switch (requestCode) {
|
||||
case REQUEST_COLOR:
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
if (!Helper.isPro(getContext())) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
|
||||
return;
|
||||
}
|
||||
|
||||
Bundle args = data.getBundleExtra("args");
|
||||
setColor(args.getInt("color"));
|
||||
if (Helper.isPro(getContext())) {
|
||||
Bundle args = data.getBundleExtra("args");
|
||||
setColor(args.getInt("color"));
|
||||
} else
|
||||
Toast.makeText(getContext(), R.string.title_pro_feature, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
break;
|
||||
case REQUEST_SAVE:
|
||||
|
|
|
@ -430,7 +430,7 @@ public class FragmentRule extends FragmentBase {
|
|||
if (resultCode == RESULT_OK && data != null) {
|
||||
if (!Helper.isPro(getContext())) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
|
||||
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ import androidx.constraintlayout.widget.ConstraintLayout;
|
|||
import androidx.core.content.ContextCompat;
|
||||
import androidx.exifinterface.media.ExifInterface;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
@ -677,15 +676,18 @@ public class Helper {
|
|||
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("pro", false);
|
||||
}
|
||||
|
||||
static void linkPro(TextView tv) {
|
||||
tv.getPaint().setUnderlineText(true);
|
||||
tv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(view.getContext());
|
||||
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
|
||||
}
|
||||
});
|
||||
static void linkPro(final TextView tv) {
|
||||
final Intent pro = new Intent(Intent.ACTION_VIEW, Uri.parse(BuildConfig.PRO_FEATURES_URI));
|
||||
PackageManager pm = tv.getContext().getPackageManager();
|
||||
if (pro.resolveActivity(pm) != null) {
|
||||
tv.getPaint().setUnderlineText(true);
|
||||
tv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
tv.getContext().startActivity(pro);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> List<List<T>> chunkList(List<T> list, int size) {
|
||||
|
|
Loading…
Reference in New Issue