Fixable errors
This commit is contained in:
parent
af69271f89
commit
51751e7077
@ -47,4 +47,12 @@ public final class AndroidUtils2 {
|
|||||||
|
|
||||||
pm.setComponentEnabledSetting(new ComponentName(context, componentClass), componentState, PackageManager.DONT_KILL_APP);
|
pm.setComponentEnabledSetting(new ComponentName(context, componentClass), componentState, PackageManager.DONT_KILL_APP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isComponentEnabled(@NotNull Context context,
|
||||||
|
@NotNull Class<? extends Context> componentClass) {
|
||||||
|
final PackageManager pm = context.getPackageManager();
|
||||||
|
|
||||||
|
int componentEnabledSetting = pm.getComponentEnabledSetting(new ComponentName(context, componentClass));
|
||||||
|
return componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_ENABLED || componentEnabledSetting == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
|
||||||
|
}
|
||||||
}
|
}
|
@ -42,7 +42,7 @@ public class CalculatorFixableMessage implements Parcelable {
|
|||||||
private final MessageType messageType;
|
private final MessageType messageType;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final CalculatorFixableError fixableError;
|
private final FixableError fixableError;
|
||||||
|
|
||||||
public CalculatorFixableMessage(@NotNull Message message) {
|
public CalculatorFixableMessage(@NotNull Message message) {
|
||||||
this.message = message.getLocalizedMessage();
|
this.message = message.getLocalizedMessage();
|
||||||
@ -81,7 +81,7 @@ public class CalculatorFixableMessage implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public CalculatorFixableError getFixableError() {
|
public FixableError getFixableError() {
|
||||||
return fixableError;
|
return fixableError;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,6 +15,7 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.actionbarsherlock.app.SherlockActivity;
|
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.common.msg.Message;
|
import org.solovyev.common.msg.Message;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -85,7 +86,7 @@ public class CalculatorMessagesDialog extends SherlockActivity {
|
|||||||
calculationMessagesTextView.setText(message.getMessage());
|
calculationMessagesTextView.setText(message.getMessage());
|
||||||
|
|
||||||
final Button fixButton = (Button) view.findViewById(R.id.fix_button);
|
final Button fixButton = (Button) view.findViewById(R.id.fix_button);
|
||||||
final CalculatorFixableError fixableError = message.getFixableError();
|
final FixableError fixableError = message.getFixableError();
|
||||||
if (fixableError == null) {
|
if (fixableError == null) {
|
||||||
fixButton.setVisibility(View.GONE);
|
fixButton.setVisibility(View.GONE);
|
||||||
fixButton.setOnClickListener(null);
|
fixButton.setOnClickListener(null);
|
@ -1,14 +1,29 @@
|
|||||||
package org.solovyev.android.calculator.onscreen;
|
package org.solovyev.android.calculator.onscreen;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import org.solovyev.android.AndroidUtils2;
|
||||||
|
import org.solovyev.android.prefs.BooleanPreference;
|
||||||
|
import org.solovyev.android.prefs.Preference;
|
||||||
|
|
||||||
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)) {
|
||||||
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
if (!removeIconDialogShown.getPreference(prefs)) {
|
||||||
|
|
||||||
|
removeIconDialogShown.putPreference(prefs, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CalculatorOnscreenService.showOnscreenView(this);
|
CalculatorOnscreenService.showOnscreenView(this);
|
||||||
|
|
||||||
this.finish();
|
this.finish();
|
||||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
* Date: 11/17/12
|
* Date: 11/17/12
|
||||||
* Time: 7:30 PM
|
* Time: 7:30 PM
|
||||||
*/
|
*/
|
||||||
public enum CalculatorFixableError {
|
public enum CalculatorFixableError implements FixableError {
|
||||||
|
|
||||||
must_be_rad(Messages.msg_23, Messages.msg_24, Messages.msg_25) {
|
must_be_rad(Messages.msg_23, Messages.msg_24, Messages.msg_25) {
|
||||||
@Override
|
@Override
|
||||||
@ -53,5 +53,4 @@ public enum CalculatorFixableError {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void fix();
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User: serso
|
||||||
|
* Date: 12/2/12
|
||||||
|
* Time: 10:21 PM
|
||||||
|
*/
|
||||||
|
public interface FixableError extends Serializable {
|
||||||
|
|
||||||
|
void fix();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user