Make all activities use a toolbar.

Updated the watch/pass screen to use a top switch bar.
Removed up navigation stuff.
material
Floens 11 years ago
parent 60d3e7671e
commit 08efbdcdd8
  1. 42
      Clover/app/src/main/AndroidManifest.xml
  2. 11
      Clover/app/src/main/java/org/floens/chan/ui/ThemeActivity.java
  3. 11
      Clover/app/src/main/java/org/floens/chan/ui/activity/AboutActivity.java
  4. 12
      Clover/app/src/main/java/org/floens/chan/ui/activity/AdvancedSettingsActivity.java
  5. 15
      Clover/app/src/main/java/org/floens/chan/ui/activity/BoardEditor.java
  6. 11
      Clover/app/src/main/java/org/floens/chan/ui/activity/DeveloperActivity.java
  7. 70
      Clover/app/src/main/java/org/floens/chan/ui/activity/PassSettingsActivity.java
  8. 5
      Clover/app/src/main/java/org/floens/chan/ui/activity/ReplyActivity.java
  9. 16
      Clover/app/src/main/java/org/floens/chan/ui/activity/SettingsActivity.java
  10. 74
      Clover/app/src/main/java/org/floens/chan/ui/activity/WatchSettingsActivity.java
  11. 2
      Clover/app/src/main/res/layout/board_select_add.xml
  12. 71
      Clover/app/src/main/res/layout/header_switch_layout.xml
  13. 17
      Clover/app/src/main/res/layout/preference_pass.xml
  14. 2
      Clover/app/src/main/res/layout/toolbar_activity.xml
  15. 32
      Clover/app/src/main/res/layout/watch_description.xml
  16. 9
      Clover/app/src/main/res/menu/action_bar_switch.xml
  17. 14
      Clover/app/src/main/res/menu/board_edit.xml
  18. 15
      Clover/app/src/main/res/menu/image_view.xml
  19. 5
      Clover/app/src/main/res/menu/settings.xml
  20. 2
      Clover/app/src/main/res/values/strings.xml

@ -80,45 +80,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:windowSoftInputMode="adjustResize" /> android:windowSoftInputMode="adjustResize" />
<activity <activity
android:name="org.floens.chan.ui.activity.SettingsActivity" android:name="org.floens.chan.ui.activity.SettingsActivity"
android:label="@string/action_settings" android:label="@string/action_settings" />
android:parentActivityName=".ui.activity.ChanActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.floens.chan.ui.activity.BoardActivity" />
</activity>
<activity <activity
android:name="org.floens.chan.ui.activity.WatchSettingsActivity" android:name="org.floens.chan.ui.activity.WatchSettingsActivity"
android:label="@string/preference_watch_settings" android:label="@string/preference_watch_settings" />
android:parentActivityName=".ui.activity.ChanActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.floens.chan.ui.activity.BoardActivity" />
</activity>
<activity <activity
android:name="org.floens.chan.ui.activity.PassSettingsActivity" android:name="org.floens.chan.ui.activity.PassSettingsActivity"
android:label="@string/preference_pass_settings" android:label="@string/preference_pass_settings" />
android:parentActivityName=".ui.activity.ChanActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.floens.chan.ui.activity.BoardActivity" />
</activity>
<activity <activity
android:name="org.floens.chan.ui.activity.AboutActivity" android:name="org.floens.chan.ui.activity.AboutActivity"
android:label="@string/preference_about" android:label="@string/preference_about" />
android:parentActivityName=".ui.activity.ChanActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.floens.chan.ui.activity.BoardActivity" />
</activity>
<activity <activity
android:name="org.floens.chan.ui.activity.BoardEditor" android:name="org.floens.chan.ui.activity.BoardEditor"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/board_edit" android:label="@string/board_edit" />
android:parentActivityName=".ui.activity.ChanActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.floens.chan.ui.activity.BoardActivity" />
</activity>
<activity <activity
android:name="org.floens.chan.ui.activity.ImageViewActivity" android:name="org.floens.chan.ui.activity.ImageViewActivity"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
@ -128,12 +103,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<activity android:name="org.floens.chan.ui.activity.DeveloperActivity" /> <activity android:name="org.floens.chan.ui.activity.DeveloperActivity" />
<activity <activity
android:name="org.floens.chan.ui.activity.AdvancedSettingsActivity" android:name="org.floens.chan.ui.activity.AdvancedSettingsActivity"
android:label="@string/settings_advanced_label" android:label="@string/settings_advanced_label" />
android:parentActivityName=".ui.activity.ChanActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="org.floens.chan.ui.activity.BoardActivity" />
</activity>
<service <service
android:name=".ui.service.WatchNotifier" android:name=".ui.service.WatchNotifier"

@ -19,6 +19,7 @@ package org.floens.chan.ui;
import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import org.floens.chan.R; import org.floens.chan.R;
import org.floens.chan.utils.ThemeHelper; import org.floens.chan.utils.ThemeHelper;
@ -34,4 +35,14 @@ public class ThemeActivity extends ActionBarActivity {
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
} }
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
} else {
return super.onOptionsItemSelected(item);
}
}
} }

@ -17,18 +17,21 @@
*/ */
package org.floens.chan.ui.activity; package org.floens.chan.ui.activity;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.webkit.WebView; import android.webkit.WebView;
import org.floens.chan.utils.ThemeHelper; import org.floens.chan.R;
import org.floens.chan.ui.ThemeActivity;
public class AboutActivity extends Activity { public class AboutActivity extends ThemeActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ThemeHelper.setTheme(this); setTheme();
setContentView(R.layout.toolbar_activity);
setToolbar();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
WebView webView = new WebView(this); WebView webView = new WebView(this);
webView.loadUrl("file:///android_asset/html/licenses.html"); webView.loadUrl("file:///android_asset/html/licenses.html");

@ -17,7 +17,6 @@
*/ */
package org.floens.chan.ui.activity; package org.floens.chan.ui.activity;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
@ -26,19 +25,22 @@ import android.preference.PreferenceFragment;
import org.floens.chan.R; import org.floens.chan.R;
import org.floens.chan.chan.ChanUrls; import org.floens.chan.chan.ChanUrls;
import org.floens.chan.core.ChanPreferences; import org.floens.chan.core.ChanPreferences;
import org.floens.chan.ui.ThemeActivity;
import org.floens.chan.ui.fragment.FolderPickFragment; import org.floens.chan.ui.fragment.FolderPickFragment;
import org.floens.chan.utils.ThemeHelper;
import java.io.File; import java.io.File;
public class AdvancedSettingsActivity extends Activity { public class AdvancedSettingsActivity extends ThemeActivity {
@Override @Override
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ThemeHelper.setTheme(this); setTheme();
setContentView(R.layout.toolbar_activity);
setToolbar();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getFragmentManager().beginTransaction().replace(android.R.id.content, new AdvancedSettingsFragment()).commit(); getFragmentManager().beginTransaction().replace(R.id.content, new AdvancedSettingsFragment()).commit();
} }
public static class AdvancedSettingsFragment extends PreferenceFragment { public static class AdvancedSettingsFragment extends PreferenceFragment {

@ -17,7 +17,6 @@
*/ */
package org.floens.chan.ui.activity; package org.floens.chan.ui.activity;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -52,14 +51,14 @@ import org.floens.chan.core.ChanPreferences;
import org.floens.chan.core.manager.BoardManager; import org.floens.chan.core.manager.BoardManager;
import org.floens.chan.core.model.Board; import org.floens.chan.core.model.Board;
import org.floens.chan.ui.SwipeDismissListViewTouchListener; import org.floens.chan.ui.SwipeDismissListViewTouchListener;
import org.floens.chan.utils.ThemeHelper; import org.floens.chan.ui.ThemeActivity;
import org.floens.chan.utils.Utils; import org.floens.chan.utils.Utils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
public class BoardEditor extends Activity { public class BoardEditor extends ThemeActivity {
private final BoardManager boardManager = ChanApplication.getBoardManager(); private final BoardManager boardManager = ChanApplication.getBoardManager();
private List<Board> list; private List<Board> list;
@ -70,7 +69,10 @@ public class BoardEditor extends Activity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ThemeHelper.setTheme(this); setTheme();
setContentView(R.layout.toolbar_activity);
setToolbar();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
list = boardManager.getSavedBoards(); list = boardManager.getSavedBoards();
@ -150,7 +152,7 @@ public class BoardEditor extends Activity {
} }
}); });
setContentView(listView); ((ViewGroup)findViewById(R.id.content)).addView(listView);
} }
@Override @Override
@ -186,6 +188,9 @@ public class BoardEditor extends Activity {
ChanPreferences.setBoardEditorFillerEnabled(!ChanPreferences.getBoardEditorFillerEnabled()); ChanPreferences.setBoardEditorFillerEnabled(!ChanPreferences.getBoardEditorFillerEnabled());
item.setChecked(ChanPreferences.getBoardEditorFillerEnabled()); item.setChecked(ChanPreferences.getBoardEditorFillerEnabled());
return true; return true;
case android.R.id.home:
finish();
return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

@ -17,7 +17,6 @@
*/ */
package org.floens.chan.ui.activity; package org.floens.chan.ui.activity;
import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@ -25,17 +24,21 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import org.floens.chan.ChanApplication; import org.floens.chan.ChanApplication;
import org.floens.chan.R;
import org.floens.chan.core.model.SavedReply; import org.floens.chan.core.model.SavedReply;
import org.floens.chan.utils.ThemeHelper; import org.floens.chan.ui.ThemeActivity;
import java.util.Random; import java.util.Random;
public class DeveloperActivity extends Activity { public class DeveloperActivity extends ThemeActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ThemeHelper.setTheme(this); setTheme();
setContentView(R.layout.toolbar_activity);
setToolbar();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
LinearLayout wrapper = new LinearLayout(this); LinearLayout wrapper = new LinearLayout(this);
wrapper.setOrientation(LinearLayout.VERTICAL); wrapper.setOrientation(LinearLayout.VERTICAL);

@ -17,7 +17,6 @@
*/ */
package org.floens.chan.ui.activity; package org.floens.chan.ui.activity;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
@ -25,16 +24,15 @@ import android.app.ProgressDialog;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.support.v7.widget.SwitchCompat;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import org.floens.chan.ChanApplication; import org.floens.chan.ChanApplication;
@ -43,54 +41,47 @@ import org.floens.chan.core.ChanPreferences;
import org.floens.chan.core.manager.ReplyManager; import org.floens.chan.core.manager.ReplyManager;
import org.floens.chan.core.manager.ReplyManager.PassResponse; import org.floens.chan.core.manager.ReplyManager.PassResponse;
import org.floens.chan.core.model.Pass; import org.floens.chan.core.model.Pass;
import org.floens.chan.utils.ThemeHelper; import org.floens.chan.ui.ThemeActivity;
import org.floens.chan.utils.Utils; import org.floens.chan.utils.Utils;
public class PassSettingsActivity extends Activity implements OnCheckedChangeListener { public class PassSettingsActivity extends ThemeActivity implements OnCheckedChangeListener {
private static PassSettingsActivity instance; private SwitchCompat onSwitch;
private TextView toggleStatus;
private Switch enableSwitch;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ThemeHelper.setTheme(this); setTheme();
setContentView(R.layout.header_switch_layout);
instance = this; setToolbar();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setFragment(ChanPreferences.getPassEnabled()); findViewById(R.id.toggle_bar).setOnClickListener(new View.OnClickListener() {
} @Override
public void onClick(View v) {
onSwitch.toggle();
}
});
@Override toggleStatus = (TextView) findViewById(R.id.toggle_status);
protected void onDestroy() { onSwitch = (SwitchCompat) findViewById(R.id.toggle);
super.onDestroy(); onSwitch.setOnCheckedChangeListener(this);
setSwitch(ChanPreferences.getPassEnabled());
instance = null; setFragment(ChanPreferences.getPassEnabled());
} }
@Override @Override
public void onBackPressed() { public void onPause() {
super.onBackPressed(); super.onPause();
if (TextUtils.isEmpty(ChanPreferences.getPassId())) { if (TextUtils.isEmpty(ChanPreferences.getPassId())) {
ChanPreferences.setPassEnabled(false); ChanPreferences.setPassEnabled(false);
setSwitch(false);
} }
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.action_bar_switch, menu);
enableSwitch = (Switch) menu.findItem(R.id.action_bar_switch).getActionView();
enableSwitch.setOnCheckedChangeListener(this);
enableSwitch.setPadding(0, 0, Utils.dp(14), 0);
setSwitch(ChanPreferences.getPassEnabled());
return true;
}
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setFragment(isChecked); setFragment(isChecked);
@ -98,19 +89,21 @@ public class PassSettingsActivity extends Activity implements OnCheckedChangeLis
} }
private void setSwitch(boolean enabled) { private void setSwitch(boolean enabled) {
enableSwitch.setChecked(enabled); onSwitch.setChecked(enabled);
toggleStatus.setText(enabled ? R.string.on : R.string.off);
ChanPreferences.setPassEnabled(enabled); ChanPreferences.setPassEnabled(enabled);
} }
private void setFragment(boolean enabled) { private void setFragment(boolean enabled) {
if (enabled) { if (enabled) {
FragmentTransaction t = getFragmentManager().beginTransaction(); FragmentTransaction t = getFragmentManager().beginTransaction();
t.replace(android.R.id.content, new PassSettingsFragment()); t.replace(R.id.content, new PassSettingsFragment());
t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
t.commit(); t.commit();
} else { } else {
FragmentTransaction t = getFragmentManager().beginTransaction(); FragmentTransaction t = getFragmentManager().beginTransaction();
t.replace(android.R.id.content, new TextFragment()); t.replace(R.id.content, new TextFragment());
t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
t.commit(); t.commit();
} }
@ -144,10 +137,9 @@ public class PassSettingsActivity extends Activity implements OnCheckedChangeLis
login.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { login.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
if (PassSettingsActivity.instance != null) { Pass pass = new Pass(ChanPreferences.getPassToken(), ChanPreferences.getPassPin());
Pass pass = new Pass(ChanPreferences.getPassToken(), ChanPreferences.getPassPin()); onLoginClick(pass);
onLoginClick(pass);
}
return true; return true;
} }
}); });

@ -45,14 +45,13 @@ public class ReplyActivity extends ThemeActivity {
staticLoadable = null; staticLoadable = null;
if (loadable != null && savedInstanceState == null) { if (loadable != null && savedInstanceState == null) {
setContentView(R.layout.reply_activity);
setTheme(); setTheme();
setContentView(R.layout.toolbar_activity);
setToolbar(); setToolbar();
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
FragmentTransaction ft = getFragmentManager().beginTransaction(); FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.reply_fragment, ReplyFragment.newInstance(loadable, false), "reply"); ft.replace(R.id.content, ReplyFragment.newInstance(loadable, false), "reply");
ft.commitAllowingStateLoss(); ft.commitAllowingStateLoss();
} else if (savedInstanceState == null) { } else if (savedInstanceState == null) {
Logger.e(TAG, "Loadable was null, exiting!"); Logger.e(TAG, "Loadable was null, exiting!");

@ -17,17 +17,17 @@
*/ */
package org.floens.chan.ui.activity; package org.floens.chan.ui.activity;
import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import org.floens.chan.R; import org.floens.chan.R;
import org.floens.chan.ui.ThemeActivity;
import org.floens.chan.ui.fragment.SettingsFragment; import org.floens.chan.ui.fragment.SettingsFragment;
import org.floens.chan.utils.ThemeHelper; import org.floens.chan.utils.ThemeHelper;
public class SettingsActivity extends Activity { public class SettingsActivity extends ThemeActivity {
private static boolean doingThemeRestart = false; private static boolean doingThemeRestart = false;
private static ThemeHelper.Theme lastTheme; private static ThemeHelper.Theme lastTheme;
@ -35,15 +35,18 @@ public class SettingsActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setTheme();
setContentView(R.layout.toolbar_activity);
setToolbar();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (!doingThemeRestart) { if (!doingThemeRestart) {
lastTheme = ThemeHelper.getInstance().getTheme(); lastTheme = ThemeHelper.getInstance().getTheme();
} }
ThemeHelper.setTheme(this);
SettingsFragment frag = new SettingsFragment(); SettingsFragment frag = new SettingsFragment();
frag.setArguments(getIntent().getExtras()); frag.setArguments(getIntent().getExtras());
getFragmentManager().beginTransaction().replace(android.R.id.content, frag).commit(); getFragmentManager().beginTransaction().replace(R.id.content, frag).commit();
} }
public void restart(Intent intent) { public void restart(Intent intent) {
@ -77,6 +80,9 @@ public class SettingsActivity extends Activity {
if (item.getItemId() == R.id.action_settings_advanced) { if (item.getItemId() == R.id.action_settings_advanced) {
startActivity(new Intent(this, AdvancedSettingsActivity.class)); startActivity(new Intent(this, AdvancedSettingsActivity.class));
return true; return true;
} else if (item.getItemId() == android.R.id.home) {
finish();
return true;
} else { } else {
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }

@ -17,56 +17,52 @@
*/ */
package org.floens.chan.ui.activity; package org.floens.chan.ui.activity;
import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.app.FragmentTransaction; import android.app.FragmentTransaction;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.view.Gravity; import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import org.floens.chan.ChanApplication; import org.floens.chan.ChanApplication;
import org.floens.chan.R; import org.floens.chan.R;
import org.floens.chan.core.ChanPreferences; import org.floens.chan.core.ChanPreferences;
import org.floens.chan.utils.ThemeHelper; import org.floens.chan.ui.ThemeActivity;
import org.floens.chan.utils.Utils;
public class WatchSettingsActivity extends Activity implements OnCheckedChangeListener { public class WatchSettingsActivity extends ThemeActivity implements OnCheckedChangeListener {
private Switch watchSwitch; private SwitchCompat watchSwitch;
private TextView toggleStatus;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ThemeHelper.setTheme(this); setTheme();
setContentView(R.layout.header_switch_layout);
setToolbar();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setFragment(ChanPreferences.getWatchEnabled()); findViewById(R.id.toggle_bar).setOnClickListener(new View.OnClickListener() {
} @Override
public void onClick(View v) {
@Override watchSwitch.toggle();
public boolean onCreateOptionsMenu(Menu menu) { }
getMenuInflater().inflate(R.menu.action_bar_switch, menu); });
watchSwitch = (Switch) menu.findItem(R.id.action_bar_switch).getActionView(); toggleStatus = (TextView) findViewById(R.id.toggle_status);
watchSwitch = (SwitchCompat) findViewById(R.id.toggle);
watchSwitch.setOnCheckedChangeListener(this); watchSwitch.setOnCheckedChangeListener(this);
watchSwitch.setPadding(0, 0, Utils.dp(14), 0);
setSwitch(ChanPreferences.getWatchEnabled()); setSwitch(ChanPreferences.getWatchEnabled());
return true; setFragment(ChanPreferences.getWatchEnabled());
} }
@Override @Override
@ -77,30 +73,20 @@ public class WatchSettingsActivity extends Activity implements OnCheckedChangeLi
private void setSwitch(boolean enabled) { private void setSwitch(boolean enabled) {
watchSwitch.setChecked(enabled); watchSwitch.setChecked(enabled);
toggleStatus.setText(enabled ? R.string.on : R.string.off);
ChanPreferences.setWatchEnabled(enabled); ChanPreferences.setWatchEnabled(enabled);
watchSwitch.setEnabled(false);
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
watchSwitch.setEnabled(true);
}
}, 500);
} }
private void setFragment(boolean enabled) { private void setFragment(boolean enabled) {
FragmentTransaction t = getFragmentManager().beginTransaction();
if (enabled) { if (enabled) {
FragmentTransaction t = getFragmentManager().beginTransaction(); t.replace(R.id.content, new WatchSettingsFragment());
t.replace(android.R.id.content, new WatchSettingsFragment());
t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
t.commit();
} else { } else {
FragmentTransaction t = getFragmentManager().beginTransaction(); t.replace(R.id.content, TextFragment.newInstance(R.string.watch_info_text));
t.replace(android.R.id.content, TextFragment.newInstance(R.string.watch_info_text));
t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
t.commit();
} }
t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
t.commit();
} }
public static class TextFragment extends Fragment { public static class TextFragment extends Fragment {
@ -114,18 +100,10 @@ public class WatchSettingsActivity extends Activity implements OnCheckedChangeLi
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle savedInstanceState) {
LinearLayout container = new LinearLayout(inflater.getContext()); ViewGroup container = (ViewGroup) inflater.inflate(R.layout.watch_description, null);
int p = Utils.dp(14);
container.setPadding(p, p, p, p);
TextView text = new TextView(inflater.getContext()); TextView text = (TextView) container.findViewById(R.id.text);
text.setTextSize(20);
text.setText(getArguments().getInt("text_resource")); text.setText(getArguments().getInt("text_resource"));
text.setGravity(Gravity.CENTER);
container.setGravity(Gravity.CENTER);
container.addView(text);
return container; return container;
} }

@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16sp" android:textSize="16sp"
android:textColor="#FFF3F3F3" android:textColor="#ff000000"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight" android:paddingRight="?android:attr/listPreferredItemPaddingRight"

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?><!--
Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/toggle_bar"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?attr/selectableItemBackground"
android:clickable="true">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff9e9e9e">
<TextView
android:layout_gravity="center_vertical"
android:id="@+id/toggle_status"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="24dp"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:singleLine="true"
android:textColor="#ffffffff"
android:textAppearance="?android:attr/textAppearanceMedium" />
<android.support.v7.widget.SwitchCompat
android:layout_gravity="center_vertical"
android:id="@+id/toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="20dp"
android:focusable="false"
android:clickable="true" />
</LinearLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!--
<!--
Clover - 4chan browser https://github.com/Floens/Clover/ Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens Copyright (C) 2014 Floens
@ -16,21 +15,19 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<LinearLayout <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:gravity="center"> android:gravity="center"
android:padding="24dp">
<TextView <TextView
android:id="@+id/pass_info" android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:paddingTop="16dp"
android:text="@string/pass_info_text" android:text="@string/pass_info_text"
android:textSize="24sp"/> style="?android:attr/textAppearanceMedium" />
<TextView <TextView
android:id="@+id/pass_link" android:id="@+id/pass_link"
@ -42,6 +39,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
android:text="@string/pass_info_learn_more" android:text="@string/pass_info_learn_more"
android:textColor="@android:color/holo_blue_light" android:textColor="@android:color/holo_blue_light"
android:textSize="20sp" android:textSize="20sp"
android:textStyle="italic"/> android:textStyle="italic" />
</LinearLayout> </LinearLayout>

@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<include layout="@layout/toolbar" /> <include layout="@layout/toolbar" />
<FrameLayout <FrameLayout
android:id="@+id/reply_fragment" android:id="@+id/content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?><!--
Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:gravity="center">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
style="?android:attr/textAppearanceMedium" />
</LinearLayout>

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!--
<!--
Clover - 4chan browser https://github.com/Floens/Clover/ Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens Copyright (C) 2014 Floens
@ -16,13 +15,13 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/action_bar_switch" android:id="@+id/action_bar_switch"
android:title="" android:title=""
android:actionViewClass="android.widget.Switch" android:actionViewClass="android.widget.Switch"
android:showAsAction="always"> app:showAsAction="always" />
</item>
</menu> </menu>

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!--
<!--
Clover - 4chan browser https://github.com/Floens/Clover/ Clover - 4chan browser https://github.com/Floens/Clover/
Copyright (C) 2014 Floens Copyright (C) 2014 Floens
@ -16,18 +15,19 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/action_add_board" android:id="@+id/action_add_board"
android:icon="@drawable/ic_action_new" android:icon="@drawable/ic_action_new"
android:showAsAction="always" app:showAsAction="always"
android:title="@string/board_add"/> android:title="@string/board_add" />
<item <item
android:id="@+id/action_show_filler" android:id="@+id/action_show_filler"
android:showAsAction="never" app:showAsAction="never"
android:checkable="true" android:checkable="true"
android:title="@string/board_edit_enable_filler"/> android:title="@string/board_edit_enable_filler" />
</menu> </menu>

@ -15,40 +15,41 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/action_image_play_state" android:id="@+id/action_image_play_state"
android:icon="@drawable/ic_action_play" android:icon="@drawable/ic_action_play"
android:orderInCategory="1" android:orderInCategory="1"
android:showAsAction="always" app:showAsAction="always"
android:title="@string/image_play_state" /> android:title="@string/image_play_state" />
<item <item
android:id="@+id/action_image_save" android:id="@+id/action_image_save"
android:orderInCategory="2" android:orderInCategory="2"
android:showAsAction="never" app:showAsAction="never"
android:title="@string/image_save" /> android:title="@string/image_save" />
<item <item
android:id="@+id/action_open_browser" android:id="@+id/action_open_browser"
android:orderInCategory="3" android:orderInCategory="3"
android:showAsAction="never" app:showAsAction="never"
android:title="@string/action_open_browser" /> android:title="@string/action_open_browser" />
<item <item
android:id="@+id/action_share" android:id="@+id/action_share"
android:orderInCategory="4" android:orderInCategory="4"
android:showAsAction="never" app:showAsAction="never"
android:title="@string/action_share" /> android:title="@string/action_share" />
<item <item
android:id="@+id/action_image_search" android:id="@+id/action_image_search"
android:orderInCategory="5" android:orderInCategory="5"
android:showAsAction="never" app:showAsAction="never"
android:title="@string/action_search_image"> android:title="@string/action_search_image">
<menu></menu> <menu></menu>
</item> </item>
<item <item
android:id="@+id/action_download_album" android:id="@+id/action_download_album"
android:orderInCategory="6" android:orderInCategory="6"
android:showAsAction="never" app:showAsAction="never"
android:title="@string/action_download_album" /> android:title="@string/action_download_album" />
</menu> </menu>

@ -16,10 +16,11 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/action_settings_advanced" android:id="@+id/action_settings_advanced"
android:orderInCategory="1" android:orderInCategory="1"
android:showAsAction="never" app:showAsAction="never"
android:title="@string/action_settings_advanced"/> android:title="@string/action_settings_advanced"/>
</menu> </menu>

@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<string name="close">Close</string> <string name="close">Close</string>
<string name="back">Back</string> <string name="back">Back</string>
<string name="ok">OK</string> <string name="ok">OK</string>
<string name="on">On</string>
<string name="off">Off</string>
<string name="action_settings">Settings</string> <string name="action_settings">Settings</string>
<string name="action_reload">Reload</string> <string name="action_reload">Reload</string>

Loading…
Cancel
Save