message for remove onscreen icon
This commit is contained in:
parent
e35b447924
commit
061a559778
@ -279,4 +279,7 @@
|
|||||||
<string name="prefs_onscreen_show_app_icon_title">Show separate icon (require reboot)</string>
|
<string name="prefs_onscreen_show_app_icon_title">Show separate icon (require reboot)</string>
|
||||||
<string name="prefs_onscreen_show_app_icon_summary">If turned on second icon will be shown in applications\' list</string>
|
<string name="prefs_onscreen_show_app_icon_summary">If turned on second icon will be shown in applications\' list</string>
|
||||||
|
|
||||||
|
<string name="cpp_onscreen_remove_icon_message">You can remove second icon in applications\' list from application settings or by pressing next button</string>
|
||||||
|
<string name="cpp_onscreen_remove_icon_button_text">Remove icon</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -30,7 +30,7 @@ public class CalculatorFixableMessage implements Parcelable {
|
|||||||
private static CalculatorFixableMessage fromParcel(@NotNull Parcel in) {
|
private static CalculatorFixableMessage fromParcel(@NotNull Parcel in) {
|
||||||
final String message = in.readString();
|
final String message = in.readString();
|
||||||
final MessageType messageType = (MessageType) in.readSerializable();
|
final MessageType messageType = (MessageType) in.readSerializable();
|
||||||
final CalculatorFixableError fixableError = (CalculatorFixableError) in.readSerializable();
|
final FixableError fixableError = (FixableError) in.readSerializable();
|
||||||
|
|
||||||
return new CalculatorFixableMessage(message, messageType, fixableError);
|
return new CalculatorFixableMessage(message, messageType, fixableError);
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ public class CalculatorFixableMessage implements Parcelable {
|
|||||||
|
|
||||||
public CalculatorFixableMessage(@NotNull String message,
|
public CalculatorFixableMessage(@NotNull String message,
|
||||||
@NotNull MessageType messageType,
|
@NotNull MessageType messageType,
|
||||||
@Nullable CalculatorFixableError fixableError) {
|
@Nullable FixableError fixableError) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.messageType = messageType;
|
this.messageType = messageType;
|
||||||
this.fixableError = fixableError;
|
this.fixableError = fixableError;
|
||||||
|
@ -17,6 +17,7 @@ import com.actionbarsherlock.app.SherlockActivity;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.core.R;
|
import org.solovyev.android.calculator.core.R;
|
||||||
import org.solovyev.common.msg.Message;
|
import org.solovyev.common.msg.Message;
|
||||||
|
import org.solovyev.common.text.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -93,8 +94,15 @@ public class CalculatorMessagesDialog extends SherlockActivity {
|
|||||||
} else {
|
} else {
|
||||||
fixButton.setVisibility(View.VISIBLE);
|
fixButton.setVisibility(View.VISIBLE);
|
||||||
fixButton.setOnClickListener(new FixErrorOnClickListener(messages, message));
|
fixButton.setOnClickListener(new FixErrorOnClickListener(messages, message));
|
||||||
|
|
||||||
|
final CharSequence fixCaption = fixableError.getFixCaption();
|
||||||
|
if (!StringUtils.isEmpty(fixCaption)) {
|
||||||
|
fixButton.setText(fixCaption);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
viewGroup.addView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
viewGroup.addView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@ public final class CalculatorPreferences {
|
|||||||
public static class OnscreenCalculator {
|
public static class OnscreenCalculator {
|
||||||
public static final Preference<Boolean> startOnBoot = new BooleanPreference("onscreen_start_on_boot", false);
|
public static final Preference<Boolean> startOnBoot = new BooleanPreference("onscreen_start_on_boot", false);
|
||||||
public static final Preference<Boolean> showAppIcon = new BooleanPreference("onscreen_show_app_icon", true);
|
public static final Preference<Boolean> showAppIcon = new BooleanPreference("onscreen_show_app_icon", true);
|
||||||
}
|
public static final Preference<Boolean> removeIconDialogShown = new BooleanPreference("onscreen_remove_icon_dialog_shown", false);
|
||||||
|
}
|
||||||
|
|
||||||
public static class Calculations {
|
public static class Calculations {
|
||||||
|
|
||||||
|
@ -1,26 +1,33 @@
|
|||||||
package org.solovyev.android.calculator.onscreen;
|
package org.solovyev.android.calculator.onscreen;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.AndroidUtils2;
|
import org.solovyev.android.AndroidUtils2;
|
||||||
import org.solovyev.android.prefs.BooleanPreference;
|
import org.solovyev.android.calculator.AbstractFixableError;
|
||||||
import org.solovyev.android.prefs.Preference;
|
import org.solovyev.android.calculator.App;
|
||||||
|
import org.solovyev.android.calculator.CalculatorFixableMessage;
|
||||||
|
import org.solovyev.android.calculator.CalculatorMessagesDialog;
|
||||||
|
import org.solovyev.android.calculator.CalculatorPreferences;
|
||||||
|
import org.solovyev.common.msg.MessageType;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class CalculatorOnscreenStartActivity extends Activity {
|
public class CalculatorOnscreenStartActivity extends Activity {
|
||||||
|
|
||||||
private static final Preference<Boolean> removeIconDialogShown = new BooleanPreference("onscreen_remove_icon_dialog_shown", false);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if (AndroidUtils2.isComponentEnabled(this, CalculatorOnscreenStartActivity.class)) {
|
if (AndroidUtils2.isComponentEnabled(this, CalculatorOnscreenStartActivity.class)) {
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
if (!removeIconDialogShown.getPreference(prefs)) {
|
|
||||||
|
|
||||||
removeIconDialogShown.putPreference(prefs, true);
|
if (!CalculatorPreferences.OnscreenCalculator.removeIconDialogShown.getPreference(prefs)) {
|
||||||
|
CalculatorMessagesDialog.showDialog(Arrays.asList(new CalculatorFixableMessage(getString(R.string.cpp_onscreen_remove_icon_message), MessageType.warning, new RemoveIconFixableError(this))), this);
|
||||||
|
CalculatorPreferences.OnscreenCalculator.removeIconDialogShown.putPreference(prefs, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,4 +35,18 @@ public class CalculatorOnscreenStartActivity extends Activity {
|
|||||||
|
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class RemoveIconFixableError extends AbstractFixableError {
|
||||||
|
|
||||||
|
public RemoveIconFixableError(@NotNull Context context) {
|
||||||
|
super(context.getString(R.string.cpp_onscreen_remove_icon_button_text));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fix() {
|
||||||
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(App.getInstance().getApplication());
|
||||||
|
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(prefs, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public abstract class AbstractFixableError implements FixableError {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String fixCaption;
|
||||||
|
|
||||||
|
protected AbstractFixableError() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractFixableError(@Nullable String fixCaption) {
|
||||||
|
this.fixCaption = fixCaption;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public CharSequence getFixCaption() {
|
||||||
|
return fixCaption;
|
||||||
|
}
|
||||||
|
}
|
@ -53,4 +53,10 @@ public enum CalculatorFixableError implements FixableError {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public CharSequence getFixCaption() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9,5 +11,8 @@ import java.io.Serializable;
|
|||||||
*/
|
*/
|
||||||
public interface FixableError extends Serializable {
|
public interface FixableError extends Serializable {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
CharSequence getFixCaption();
|
||||||
|
|
||||||
void fix();
|
void fix();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user