Remove ActivityUi

This commit is contained in:
serso
2016-03-01 11:57:48 +01:00
parent 6427c91953
commit a6bb109514
17 changed files with 338 additions and 396 deletions

View File

@@ -9,12 +9,12 @@ import android.support.annotation.StringRes;
import android.support.annotation.XmlRes;
import android.util.SparseArray;
import org.solovyev.android.calculator.ActivityUi;
import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.AppComponent;
import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.language.Languages;
import org.solovyev.android.checkout.ActivityCheckout;
import org.solovyev.android.checkout.Billing;
import org.solovyev.android.checkout.Checkout;
@@ -29,20 +29,20 @@ public class PreferencesActivity extends BaseActivity implements SharedPreferenc
static final String EXTRA_PREFERENCE_TITLE = "preference-title";
@Nonnull
private static final SparseArray<PrefDef> preferences = new SparseArray<>();
private static final SparseArray<PrefDef> preferenceDefs = new SparseArray<>();
public static Class<? extends PreferencesActivity> getClass(@NonNull Context context) {
return App.isTablet(context) ? Dialog.class : PreferencesActivity.class;
}
static {
preferences.append(R.xml.preferences, new PrefDef("screen-main", R.string.cpp_settings));
preferences.append(R.xml.preferences_calculations, new PrefDef("screen-calculations", R.string.c_prefs_calculations_category));
preferences.append(R.xml.preferences_appearance, new PrefDef("screen-appearance", R.string.c_prefs_appearance_category));
preferences.append(R.xml.preferences_plot, new PrefDef("screen-plot", R.string.prefs_graph_screen_title));
preferences.append(R.xml.preferences_other, new PrefDef("screen-other", R.string.c_prefs_other_category));
preferences.append(R.xml.preferences_onscreen, new PrefDef("screen-onscreen", R.string.prefs_onscreen_title));
preferences.append(R.xml.preferences_widget, new PrefDef("screen-widget", R.string.prefs_widget_title));
preferenceDefs.append(R.xml.preferences, new PrefDef("screen-main", R.string.cpp_settings));
preferenceDefs.append(R.xml.preferences_calculations, new PrefDef("screen-calculations", R.string.c_prefs_calculations_category));
preferenceDefs.append(R.xml.preferences_appearance, new PrefDef("screen-appearance", R.string.c_prefs_appearance_category));
preferenceDefs.append(R.xml.preferences_plot, new PrefDef("screen-plot", R.string.prefs_graph_screen_title));
preferenceDefs.append(R.xml.preferences_other, new PrefDef("screen-other", R.string.c_prefs_other_category));
preferenceDefs.append(R.xml.preferences_onscreen, new PrefDef("screen-onscreen", R.string.prefs_onscreen_title));
preferenceDefs.append(R.xml.preferences_widget, new PrefDef("screen-widget", R.string.prefs_widget_title));
}
ActivityCheckout checkout;
@@ -52,14 +52,18 @@ public class PreferencesActivity extends BaseActivity implements SharedPreferenc
Billing billing;
@Inject
Products products;
@Inject
SharedPreferences preferences;
@Inject
Languages languages;
public PreferencesActivity() {
super(R.layout.activity_empty);
}
@Nonnull
static SparseArray<PrefDef> getPreferences() {
return preferences;
static SparseArray<PrefDef> getPreferenceDefs() {
return preferenceDefs;
}
public static void showPlotPreferences(@Nonnull Context context) {
@@ -113,9 +117,9 @@ public class PreferencesActivity extends BaseActivity implements SharedPreferenc
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (!paused) {
if (Preferences.Gui.theme.isSameKey(key)) {
ActivityUi.restartIfThemeChanged(this, ui.getTheme());
restartIfThemeChanged();
} else if (Preferences.Gui.language.isSameKey(key)) {
ActivityUi.restartIfLanguageChanged(this, ui.getLanguage());
restartIfLanguageChanged();
}
}
}

View File

@@ -1,8 +1,5 @@
package org.solovyev.android.calculator.preferences;
import static org.solovyev.android.calculator.wizard.CalculatorWizards.DEFAULT_WIZARD_FLOW;
import static org.solovyev.android.wizard.WizardUi.startWizard;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
@@ -31,6 +28,9 @@ import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static org.solovyev.android.calculator.wizard.CalculatorWizards.DEFAULT_WIZARD_FLOW;
import static org.solovyev.android.wizard.WizardUi.startWizard;
public class PreferencesFragment extends org.solovyev.android.material.preferences.PreferencesFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
private static boolean SUPPORT_HEADERS = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
@@ -70,7 +70,7 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc
final int preference = getPreferencesResId();
if (preference == R.xml.preferences) {
final SparseArray<PreferencesActivity.PrefDef> preferences = PreferencesActivity.getPreferences();
final SparseArray<PreferencesActivity.PrefDef> preferences = PreferencesActivity.getPreferenceDefs();
for (int i = 0; i < preferences.size(); i++) {
final int xml = preferences.keyAt(i);
final PreferencesActivity.PrefDef def = preferences.valueAt(i);

View File

@@ -30,8 +30,9 @@ import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import org.solovyev.android.calculator.ActivityUi;
import org.solovyev.android.calculator.App;
import org.solovyev.android.calculator.BaseActivity;
import org.solovyev.android.calculator.BaseDialogFragment;
import org.solovyev.android.calculator.R;
import org.solovyev.android.checkout.*;
@@ -68,12 +69,12 @@ public class PurchaseDialogActivity extends AppCompatActivity implements Request
@Override
protected void onStart() {
super.onStart();
ActivityUi.reportActivityStart(this);
BaseActivity.reportActivityStart(this);
}
@Override
protected void onStop() {
ActivityUi.reportActivityStop(this);
BaseActivity.reportActivityStop(this);
super.onStop();
}