Add gallery menu
This commit is contained in:
1 parent
2724a647f6
commit
be09ad6c27
7 files changed
+175
-10
No files matched your search
@@ -136,16 +136,35 @@ public class Settings {
|
||||
private static final String KEY_READING_DIRECTION = "reading_direction";
|
||||
private static final int DEFAULT_READING_DIRECTION = GalleryView.LAYOUT_MODE_RIGHT_TO_LEFT;
|
||||
|
||||
@SuppressWarnings("WrongConstant")
|
||||
@GalleryView.LayoutMode
|
||||
public static int getReadingDirection() {
|
||||
int value = getIntFromStr(KEY_READING_DIRECTION, DEFAULT_READING_DIRECTION);
|
||||
if (value != GalleryView.LAYOUT_MODE_LEFT_TO_RIGHT &&
|
||||
value != GalleryView.LAYOUT_MODE_RIGHT_TO_LEFT &&
|
||||
value != GalleryView.LAYOUT_MODE_TOP_TO_BOTTOM) {
|
||||
value = GalleryView.LAYOUT_MODE_RIGHT_TO_LEFT;
|
||||
}
|
||||
return value;
|
||||
return GalleryView.sanitizeLayoutMode(getIntFromStr(KEY_READING_DIRECTION, DEFAULT_READING_DIRECTION));
|
||||
}
|
||||
|
||||
public static void putReadingDirection(int value) {
|
||||
putIntToStr(KEY_READING_DIRECTION, value);
|
||||
}
|
||||
|
||||
private static final String KEY_SHOW_CLOCK = "gallery_show_clock";
|
||||
private static final boolean DEFAULT_SHOW_CLOCK = true;
|
||||
|
||||
public static boolean getShowClock() {
|
||||
return getBoolean(KEY_SHOW_CLOCK, DEFAULT_SHOW_CLOCK);
|
||||
}
|
||||
|
||||
public static void putShowClock(boolean value) {
|
||||
putBoolean(KEY_SHOW_CLOCK, value);
|
||||
}
|
||||
|
||||
private static final String KEY_SHOW_BATTERY = "gallery_show_battery";
|
||||
private static final boolean DEFAULT_SHOW_BATTERY = true;
|
||||
|
||||
public static boolean getShowBattery() {
|
||||
return getBoolean(KEY_SHOW_BATTERY, DEFAULT_SHOW_BATTERY);
|
||||
}
|
||||
|
||||
public static void putShowBattery(boolean value) {
|
||||
putBoolean(KEY_SHOW_BATTERY, value);
|
||||
}
|
||||
|
||||
private static final String KEY_VOLUME_PAGE = "volume_page";
|
||||
@@ -155,6 +174,10 @@ public class Settings {
|
||||
return getBoolean(KEY_VOLUME_PAGE, DEFAULT_VOLUME_PAGE);
|
||||
}
|
||||
|
||||
public static void putVolumePage(boolean value) {
|
||||
putBoolean(KEY_VOLUME_PAGE, value);
|
||||
}
|
||||
|
||||
public static final String KEY_DOWNLOAD_SAVE_SCHEME = "image_scheme";
|
||||
public static final String KEY_DOWNLOAD_SAVE_AUTHORITY = "image_authority";
|
||||
public static final String KEY_DOWNLOAD_SAVE_PATH = "image_path";
|
||||
|
||||
@@ -247,6 +247,17 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
mPageTextTexture = null;
|
||||
}
|
||||
|
||||
@LayoutMode
|
||||
public static int sanitizeLayoutMode(int layoutMode) {
|
||||
if (layoutMode != GalleryView.LAYOUT_MODE_LEFT_TO_RIGHT &&
|
||||
layoutMode != GalleryView.LAYOUT_MODE_RIGHT_TO_LEFT &&
|
||||
layoutMode != GalleryView.LAYOUT_MODE_TOP_TO_BOTTOM) {
|
||||
return GalleryView.LAYOUT_MODE_RIGHT_TO_LEFT;
|
||||
} else {
|
||||
return layoutMode;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLayoutMode() {
|
||||
return mLayoutMode;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,10 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.anani.AnimationUtils;
|
||||
@@ -81,6 +83,10 @@ public class GalleryActivity extends AppCompatActivity
|
||||
private SystemUiHelper mSystemUiHelper;
|
||||
private boolean mSystemUiShowing = false;
|
||||
|
||||
@Nullable
|
||||
private View mClock;
|
||||
@Nullable
|
||||
private View mBattery;
|
||||
@Nullable
|
||||
private View mSliderPanel;
|
||||
@Nullable
|
||||
@@ -201,6 +207,16 @@ public class GalleryActivity extends AppCompatActivity
|
||||
mSystemUiShowing = true;
|
||||
}
|
||||
|
||||
mClock = findViewById(R.id.clock);
|
||||
mBattery = findViewById(R.id.battery);
|
||||
|
||||
if (mClock != null && !Settings.getShowClock()) {
|
||||
mClock.setVisibility(View.GONE);
|
||||
}
|
||||
if (mBattery != null && !Settings.getShowBattery()) {
|
||||
mBattery.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mSliderPanel = findViewById(R.id.slider_panel);
|
||||
mLeftText = (TextView) mSliderPanel.findViewById(R.id.left);
|
||||
mRightText = (TextView) mSliderPanel.findViewById(R.id.right);
|
||||
@@ -481,6 +497,56 @@ public class GalleryActivity extends AppCompatActivity
|
||||
SimpleHandler.getInstance().post(task);
|
||||
}
|
||||
|
||||
private class GalleryMenuHelper implements DialogInterface.OnClickListener {
|
||||
|
||||
private final View mView;
|
||||
private final Spinner mReadingDirection;
|
||||
private final SwitchCompat mShowClock;
|
||||
private final SwitchCompat mShowBattery;
|
||||
private final SwitchCompat mVolumePage;
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
public GalleryMenuHelper() {
|
||||
mView = getLayoutInflater().inflate(R.layout.dialog_gallery_menu, null);
|
||||
mReadingDirection = (Spinner) mView.findViewById(R.id.reading_direction);
|
||||
mShowClock = (SwitchCompat) mView.findViewById(R.id.show_clock);
|
||||
mShowBattery = (SwitchCompat) mView.findViewById(R.id.show_battery);
|
||||
mVolumePage = (SwitchCompat) mView.findViewById(R.id.volume_page);
|
||||
|
||||
mReadingDirection.setSelection(Settings.getReadingDirection());
|
||||
mShowClock.setChecked(Settings.getShowClock());
|
||||
mShowBattery.setChecked(Settings.getShowBattery());
|
||||
mVolumePage.setChecked(Settings.getVolumePage());
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return mView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int layoutMode = GalleryView.sanitizeLayoutMode(mReadingDirection.getSelectedItemPosition());
|
||||
boolean showClock = mShowClock.isChecked();
|
||||
boolean showBattery = mShowBattery.isChecked();
|
||||
boolean volumePage = mVolumePage.isChecked();
|
||||
|
||||
Settings.putReadingDirection(layoutMode);
|
||||
Settings.putShowClock(showClock);
|
||||
Settings.putShowBattery(showBattery);
|
||||
Settings.putVolumePage(volumePage);
|
||||
|
||||
if (mGalleryView != null) {
|
||||
mGalleryView.setLayoutMode(layoutMode);
|
||||
}
|
||||
if (mClock != null) {
|
||||
mClock.setVisibility(showClock ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
if (mBattery != null) {
|
||||
mBattery.setVisibility(showBattery ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class NotifyTask implements Runnable {
|
||||
|
||||
public static final int KEY_LAYOUT_MODE = 0;
|
||||
@@ -499,8 +565,11 @@ public class GalleryActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
private void onTapMenuArea() {
|
||||
GalleryMenuHelper helper = new GalleryMenuHelper();
|
||||
new AlertDialog.Builder(GalleryActivity.this)
|
||||
.setTitle(R.string.gallery_menu_title).show();
|
||||
.setTitle(R.string.gallery_menu_title)
|
||||
.setView(helper.getView())
|
||||
.setPositiveButton(android.R.string.ok, helper).show();
|
||||
}
|
||||
|
||||
private void onTapSliderArea() {
|
||||
|
||||
Reference in new issue
Block a user