1
0
mirror of https://github.com/etesync/android synced 2025-02-08 21:52:47 +00:00

Remove opentasks and donate from startup dialog.

This commit is contained in:
Tom Hacohen 2017-02-08 15:46:59 +00:00
parent 47ca55f03f
commit fcc365a89e
2 changed files with 1 additions and 63 deletions

View File

@ -151,7 +151,6 @@ public class AppSettingsActivity extends AppCompatActivity {
private void resetHints() { private void resetHints() {
settings.remove(StartupDialogFragment.HINT_BATTERY_OPTIMIZATIONS); settings.remove(StartupDialogFragment.HINT_BATTERY_OPTIMIZATIONS);
settings.remove(StartupDialogFragment.HINT_OPENTASKS_NOT_INSTALLED);
Snackbar.make(getView(), R.string.app_settings_reset_hints_success, Snackbar.LENGTH_LONG).show(); Snackbar.make(getView(), R.string.app_settings_reset_hints_success, Snackbar.LENGTH_LONG).show();
} }

View File

@ -37,18 +37,14 @@ import lombok.Cleanup;
public class StartupDialogFragment extends DialogFragment { public class StartupDialogFragment extends DialogFragment {
public static final String public static final String
HINT_BATTERY_OPTIMIZATIONS = "hint_BatteryOptimizations", HINT_BATTERY_OPTIMIZATIONS = "hint_BatteryOptimizations";
HINT_GOOGLE_PLAY_ACCOUNTS_REMOVED = "hint_GooglePlayAccountsRemoved",
HINT_OPENTASKS_NOT_INSTALLED = "hint_OpenTasksNotInstalled";
private static final String ARGS_MODE = "mode"; private static final String ARGS_MODE = "mode";
enum Mode { enum Mode {
BATTERY_OPTIMIZATIONS, BATTERY_OPTIMIZATIONS,
DEVELOPMENT_VERSION, DEVELOPMENT_VERSION,
FDROID_DONATE,
GOOGLE_PLAY_ACCOUNTS_REMOVED, GOOGLE_PLAY_ACCOUNTS_REMOVED,
OPENTASKS_NOT_INSTALLED
} }
public static StartupDialogFragment[] getStartupDialogs(Context context) { public static StartupDialogFragment[] getStartupDialogs(Context context) {
@ -59,8 +55,6 @@ public class StartupDialogFragment extends DialogFragment {
if (BuildConfig.VERSION_NAME.contains("-alpha") || BuildConfig.VERSION_NAME.contains("-beta") || BuildConfig.VERSION_NAME.contains("-rc")) if (BuildConfig.VERSION_NAME.contains("-alpha") || BuildConfig.VERSION_NAME.contains("-beta") || BuildConfig.VERSION_NAME.contains("-rc"))
dialogs.add(StartupDialogFragment.instantiate(Mode.DEVELOPMENT_VERSION)); dialogs.add(StartupDialogFragment.instantiate(Mode.DEVELOPMENT_VERSION));
else
dialogs.add(StartupDialogFragment.instantiate(Mode.FDROID_DONATE));
// battery optimization whitelisting // battery optimization whitelisting
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && settings.getBoolean(HINT_BATTERY_OPTIMIZATIONS, true)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && settings.getBoolean(HINT_BATTERY_OPTIMIZATIONS, true)) {
@ -69,10 +63,6 @@ public class StartupDialogFragment extends DialogFragment {
dialogs.add(StartupDialogFragment.instantiate(Mode.BATTERY_OPTIMIZATIONS)); dialogs.add(StartupDialogFragment.instantiate(Mode.BATTERY_OPTIMIZATIONS));
} }
// OpenTasks information
if (!LocalTaskList.tasksProviderAvailable(context) && settings.getBoolean(HINT_OPENTASKS_NOT_INSTALLED, true))
dialogs.add(StartupDialogFragment.instantiate(Mode.OPENTASKS_NOT_INSTALLED));
Collections.reverse(dialogs); Collections.reverse(dialogs);
return dialogs.toArray(new StartupDialogFragment[dialogs.size()]); return dialogs.toArray(new StartupDialogFragment[dialogs.size()]);
} }
@ -139,57 +129,6 @@ public class StartupDialogFragment extends DialogFragment {
} }
}) })
.create(); .create();
case FDROID_DONATE:
return new AlertDialog.Builder(getActivity())
.setIcon(R.mipmap.ic_launcher)
.setTitle(R.string.startup_donate)
.setMessage(R.string.startup_donate_message)
.setPositiveButton(R.string.startup_donate_now, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(Intent.ACTION_VIEW, Constants.webUri.buildUpon().appendEncodedPath("donate/").build()));
}
})
.setNegativeButton(R.string.startup_donate_later, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.create();
case OPENTASKS_NOT_INSTALLED:
StringBuilder builder = new StringBuilder(getString(R.string.startup_opentasks_not_installed_message));
if (Build.VERSION.SDK_INT < 23)
builder.append("\n\n").append(getString(R.string.startup_opentasks_reinstall_davdroid));
return new AlertDialog.Builder(getActivity())
.setIcon(R.drawable.ic_alarm_on_dark)
.setTitle(R.string.startup_opentasks_not_installed)
.setMessage(builder.toString())
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setNeutralButton(R.string.startup_opentasks_not_installed_install, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=org.dmfs.tasks"));
if (intent.resolveActivity(getContext().getPackageManager()) != null)
getContext().startActivity(intent);
else
App.log.warning("No market app available, can't install OpenTasks");
}
})
.setNegativeButton(R.string.startup_dont_show_again, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@Cleanup ServiceDB.OpenHelper dbHelper = new ServiceDB.OpenHelper(getContext());
Settings settings = new Settings(dbHelper.getWritableDatabase());
settings.putBoolean(HINT_OPENTASKS_NOT_INSTALLED, false);
}
})
.create();
} }
throw new IllegalArgumentException(/* illegal mode argument */); throw new IllegalArgumentException(/* illegal mode argument */);