Add hint for the history enable disable switch

multisite
Floens 10 years ago
parent 8ac8266237
commit 7164ba0c54
  1. 6
      Clover/app/src/main/java/org/floens/chan/core/settings/ChanSettings.java
  2. 18
      Clover/app/src/main/java/org/floens/chan/core/settings/CounterSetting.java
  3. 13
      Clover/app/src/main/java/org/floens/chan/ui/controller/HistoryController.java
  4. 3
      Clover/app/src/main/java/org/floens/chan/ui/controller/MainSettingsController.java
  5. 1
      Clover/app/src/main/res/values/strings.xml

@ -115,7 +115,8 @@ public class ChanSettings {
public static final StringSetting proxyAddress;
public static final IntegerSetting proxyPort;
public static final IntegerSetting settingsOpenCounter;
public static final CounterSetting settingsOpenCounter;
public static final CounterSetting historyOpenCounter;
static {
SharedPreferences p = AndroidUtils.getPreferences();
@ -211,7 +212,8 @@ public class ChanSettings {
});
loadProxy();
settingsOpenCounter = new IntegerSetting(p, "counter_settings_open", 0);
settingsOpenCounter = new CounterSetting(p, "counter_settings_open");
historyOpenCounter = new CounterSetting(p, "counter_history_open");
// Old (but possibly still in some users phone)
// preference_board_view_mode default "list"

@ -0,0 +1,18 @@
package org.floens.chan.core.settings;
import android.content.SharedPreferences;
public class CounterSetting extends IntegerSetting {
public CounterSetting(SharedPreferences sharedPreferences, String key) {
super(sharedPreferences, key, 0);
}
public CounterSetting(SharedPreferences sharedPreferences, String key, SettingCallback<Integer> callback) {
super(sharedPreferences, key, 0, callback);
}
public int increase() {
set(get() + 1);
return get();
}
}

@ -38,6 +38,7 @@ import org.floens.chan.core.database.DatabaseManager;
import org.floens.chan.core.model.Board;
import org.floens.chan.core.model.History;
import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.ui.helper.HintPopup;
import org.floens.chan.ui.toolbar.ToolbarMenu;
import org.floens.chan.ui.toolbar.ToolbarMenuItem;
import org.floens.chan.ui.view.FloatingMenuItem;
@ -77,10 +78,10 @@ public class HistoryController extends Controller implements CompoundButton.OnCh
view = inflateRes(R.layout.controller_history);
SwitchCompat globalSwitch = new SwitchCompat(context);
globalSwitch.setChecked(ChanSettings.historyEnabled.get());
globalSwitch.setOnCheckedChangeListener(this);
navigationItem.rightView = globalSwitch;
SwitchCompat historyEnabledSwitch = new SwitchCompat(context);
historyEnabledSwitch.setChecked(ChanSettings.historyEnabled.get());
historyEnabledSwitch.setOnCheckedChangeListener(this);
navigationItem.rightView = historyEnabledSwitch;
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
@ -89,6 +90,10 @@ public class HistoryController extends Controller implements CompoundButton.OnCh
adapter = new HistoryAdapter();
recyclerView.setAdapter(adapter);
adapter.load();
if (ChanSettings.historyOpenCounter.increase() == 1) {
HintPopup.show(context, historyEnabledSwitch, R.string.history_toggle_hint);
}
}
@Override

@ -99,8 +99,7 @@ public class MainSettingsController extends SettingsController implements Toolba
developerView.view.getLayoutParams().height = 0;
}
ChanSettings.settingsOpenCounter.set(ChanSettings.settingsOpenCounter.get() + 1);
if (ChanSettings.settingsOpenCounter.get() == 3) {
if (ChanSettings.settingsOpenCounter.increase() == 3) {
ImageView view = overflow.getView();
view.startAnimation(android.view.animation.AnimationUtils.loadAnimation(context, R.anim.menu_overflow_shake));
advancedSettingsHint = HintPopup.show(context, view, R.string.settings_advanced_hint);

@ -224,6 +224,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="history_clear">Clear history</string>
<string name="history_clear_confirm">Clear history?</string>
<string name="history_clear_confirm_button">Clear</string>
<string name="history_toggle_hint">Enable or disable history</string>
<string name="drawer_board">Board</string>
<string name="drawer_catalog">Catalog</string>

Loading…
Cancel
Save