Skip to content

Commit

Permalink
added sub scaling image alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
dnldsht committed Sep 26, 2016
1 parent 3c373c4 commit 6babaad
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 55 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ dependencies {
compile 'org.jetbrains:annotations-java5:15.0'
compile 'com.turingtechnologies.materialscrollbar:lib:10.0.3'
compile project(':photoview')
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.5.0'
}
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="com.android.vending.BILLING" />

<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
Expand Down Expand Up @@ -85,7 +85,7 @@
<activity
android:name="org.horaapps.leafpic.activities.SingleMediaActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize|uiMode|touchscreen"
android:configChanges="orientation|screenSize|uiMode|touchscreen|screenLayout"
android:parentActivityName="org.horaapps.leafpic.activities.MainActivity"
android:theme="@style/Theme.AppCompat.NoActionBar">
<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class SettingsActivity extends ThemedActivity {
private SwitchCompat swIncludeVideo;
private SwitchCompat swSwipeDirection;
private SwitchCompat swShowFab;
private SwitchCompat swSubScaling;


@Override
Expand Down Expand Up @@ -168,6 +169,18 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});


/*** SW Show Fab ***/
swSubScaling = (SwitchCompat) findViewById(R.id.sw_sub_scaling);
swSubScaling.setChecked(SP.getBoolean(getString(R.string.preference_sub_scaling), false));
swSubScaling.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SP.putBoolean(getString(R.string.preference_sub_scaling), isChecked);
updateSwitchColor(swSubScaling, getAccentColor());
}
});

/*** SW Internal Player ***/
swInternalBrowser = (SwitchCompat) findViewById(R.id.set_internal_player);
swInternalBrowser.setChecked(SP.getBoolean(getString(R.string.preference_internal_player), false));
Expand Down Expand Up @@ -741,6 +754,7 @@ private void updateViewswithAccentColor(int color){
updateSwitchColor(swSwipeDirection, color);
updateSwitchColor(swUseMediaStore, color);
updateSwitchColor(swShowFab, color);
updateSwitchColor(swSubScaling, color);
}

@Override
Expand Down Expand Up @@ -789,20 +803,21 @@ public void onClick(View v) {
((IconicsImageView) findViewById(R.id.ll_switch_picture_orientation_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.ll_switch_max_luminosity_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.ll_switch_full_resolution_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.Traslucent_StatusBar_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.custom_3thAct_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.PrimaryColor_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.accentColor_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.traslucent_statusbar_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.custom_3thact_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.primary_color_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.accent_color_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.basic_theme_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.n_columns_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.NavBar_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.Excluded_Album_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.n_columns_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.nav_bar_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.excluded_album_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.internal_player_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.internal_include_video)).setColor(color);
((IconicsImageView) findViewById(R.id.auto_update_media_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.use_media_mediastore_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.security_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.fab_options_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.sub_scaling_Icon)).setColor(color);
((IconicsImageView) findViewById(R.id.map_provider_icon)).setColor(color);
((IconicsImageView) findViewById(R.id.media_viewer_swipe_direction_Icon)).setColor(color);

Expand All @@ -818,6 +833,7 @@ public void onClick(View v) {
((TextView) findViewById(R.id.basic_theme_item)).setTextColor(color);
((TextView) findViewById(R.id.n_columns_Item_Title)).setTextColor(color);
((TextView) findViewById(R.id.NavBar_Item)).setTextColor(color);
((TextView) findViewById(R.id.sub_scaling_Item)).setTextColor(color);
((TextView) findViewById(R.id.Excluded_Album_Item_Title)).setTextColor(color);
((TextView) findViewById(R.id.internal_player_Item)).setTextColor(color);
((TextView) findViewById(R.id.include_video_Item)).setTextColor(color);
Expand All @@ -843,6 +859,7 @@ public void onClick(View v) {
((TextView) findViewById(R.id.NavBar_Item_Sub)).setTextColor(color);
((TextView) findViewById(R.id.Excluded_Album_Item_Title_Sub)).setTextColor(color);
((TextView) findViewById(R.id.internal_player_Item_Sub)).setTextColor(color);
((TextView) findViewById(R.id.sub_scaling_Item_sub)).setTextColor(color);
((TextView) findViewById(R.id.include_video_Item_Sub)).setTextColor(color);
((TextView) findViewById(R.id.auto_update_media_Item_sub)).setTextColor(color);
((TextView) findViewById(R.id.security_item_sub)).setTextColor(color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//copyFileToDownloads(imageUri);
// TODO: 21/08/16 handle this better
if(ContentHelper.copyFile(getApplicationContext(), new File(imageUri.getPath()), new File(getAlbum().getPath()))) {
((ImageFragment) adapter.getRegisteredFragment(getAlbum().getCurrentMediaIndex())).displayMedia(true);
//((ImageFragment) adapter.getRegisteredFragment(getAlbum().getCurrentMediaIndex())).displayMedia(true);
Toast.makeText(this, R.string.new_file_created, Toast.LENGTH_SHORT).show();
}
//adapter.notifyDataSetChanged();
} catch (Exception e) {
Expand Down Expand Up @@ -648,6 +649,7 @@ public void run() {
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_IMMERSIVE);

fullScreenMode = true;
Expand Down
72 changes: 36 additions & 36 deletions app/src/main/java/org/horaapps/leafpic/fragments/ImageFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.signature.StringSignature;
import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;

import org.horaapps.leafpic.R;
import org.horaapps.leafpic.activities.SingleMediaActivity;
import org.horaapps.leafpic.data.Media;
import org.horaapps.leafpic.util.Measure;
import org.horaapps.leafpic.util.PreferenceUtil;
import org.horaapps.leafpic.views.RotateTransformation;

import java.util.Date;
Expand Down Expand Up @@ -44,25 +46,42 @@ public static ImageFragment newInstance(Media media) {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
img = getArguments().getParcelable("image");
Log.wtf("oncreate", "crezated+ " +img.getPath()) ;
}

@Override
public void onResume() {
super.onResume();
Log.wtf("onresume", "crezated"+img.getPath());

}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
PhotoView photoView = new PhotoView(getContext());
displayMedia(photoView, true);
photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
((SingleMediaActivity) getActivity()).toggleSystemUI();
}

@Override
public void onOutsidePhotoTap() {
((SingleMediaActivity) getActivity()).toggleSystemUI();
}
});
//photoView.setMaximumScale(10.0F);
return photoView;
if (PreferenceUtil.getInstance(getContext()).getBoolean(getString(R.string.preference_sub_scaling) , false)) {
SubsamplingScaleImageView imageView = new SubsamplingScaleImageView(getContext());
imageView.setImage(ImageSource.uri(img.getUri()));
return imageView;
} else {
PhotoView photoView = new PhotoView(getContext());
displayMedia(photoView, true);
photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
((SingleMediaActivity) getActivity()).toggleSystemUI();
}

@Override
public void onOutsidePhotoTap() {
((SingleMediaActivity) getActivity()).toggleSystemUI();
}
});
photoView.setMaximumScale(5.0F);
photoView.setMediumScale(3.0F);

return photoView;
}
}

/* private void rotateLoop() { //april fools
Expand Down Expand Up @@ -92,30 +111,11 @@ private void displayMedia(PhotoView photoView, boolean useCache) {
.animate(R.anim.fade_in)
.into(photoView);

/*if (SP.getBoolean("set_delay_full_image", true)) {
Ion.with(getContext())
.load(img.getPath())
.withBitmap()
.deepZoom()
.intoImageView(photoView);
} else {
Glide.with(getContext())
.load(img.getUri())
.asBitmap()
.signature(img.getSignature())
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.thumbnail(0.5f)
.animate(R.anim.fade_in)
.into(photoView);
}*/


}

public boolean rotatePicture(int rotation) {
// TODO: 28/08/16 not working yet
PhotoView photoView = (PhotoView) getView();
/*PhotoView photoView = (PhotoView) getView();
int orientation = Measure.rotateBy(img.getOrientation(), rotation);
Log.wtf("asd", img.getOrientation()+" + "+ rotation+" = " +orientation);
Expand All @@ -132,7 +132,7 @@ public boolean rotatePicture(int rotation) {
.into(photoView);
return true;
}
}*/
return false;
}
}
72 changes: 65 additions & 7 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
android:background="@drawable/ripple"
android:clickable="true">
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/n_columns_Icon"
android:id="@+id/n_columns_icon"
android:layout_width="@dimen/icon_width_height"
android:layout_height="@dimen/icon_width_height"
android:layout_gravity="center_vertical"
Expand Down Expand Up @@ -145,7 +145,7 @@
android:background="@drawable/ripple"
android:clickable="true">
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/Excluded_Album_Icon"
android:id="@+id/excluded_album_icon"
android:layout_width="@dimen/icon_width_height"
android:layout_height="@dimen/icon_width_height"
android:layout_gravity="center_vertical"
Expand Down Expand Up @@ -316,7 +316,7 @@
android:background="@drawable/ripple"
android:clickable="true">
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/PrimaryColor_Icon"
android:id="@+id/primary_color_icon"
android:layout_width="@dimen/icon_width_height"
android:layout_height="@dimen/icon_width_height"
android:layout_gravity="center_vertical"
Expand Down Expand Up @@ -358,7 +358,7 @@
android:background="@drawable/ripple"
android:clickable="true">
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/accentColor_Icon"
android:id="@+id/accent_color_icon"
android:layout_width="@dimen/icon_width_height"
android:layout_height="@dimen/icon_width_height"
android:layout_gravity="center_vertical"
Expand Down Expand Up @@ -400,7 +400,7 @@
android:background="@drawable/ripple"
android:clickable="true">
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/custom_3thAct_icon"
android:id="@+id/custom_3thact_icon"
android:layout_width="@dimen/icon_width_height"
android:layout_height="@dimen/icon_width_height"
android:layout_gravity="center_vertical"
Expand Down Expand Up @@ -442,7 +442,7 @@
android:background="@drawable/ripple"
android:clickable="true">
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/Traslucent_StatusBar_Icon"
android:id="@+id/traslucent_statusbar_icon"
android:layout_width="@dimen/icon_width_height"
android:layout_height="@dimen/icon_width_height"
android:layout_gravity="center_vertical"
Expand Down Expand Up @@ -502,7 +502,7 @@
android:background="@drawable/ripple"
android:clickable="true">
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/NavBar_Icon"
android:id="@+id/nav_bar_icon"
android:layout_width="@dimen/icon_width_height"
android:layout_height="@dimen/icon_width_height"
android:layout_gravity="center_vertical"
Expand Down Expand Up @@ -986,6 +986,64 @@
android:textSize="@dimen/medium_text"
android:textStyle="bold" />


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ll_sub_scaling"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/ripple"
android:clickable="true">
<com.mikepenz.iconics.view.IconicsImageView
android:id="@+id/sub_scaling_Icon"
android:layout_width="@dimen/icon_width_height"
android:layout_height="@dimen/icon_width_height"
android:layout_gravity="center_vertical"
app:iiv_icon="gmd-photo-library"
android:layout_marginLeft="@dimen/big_spacing"
android:layout_marginRight="@dimen/big_spacing" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="@dimen/medium_spacing"
android:paddingRight="@dimen/medium_text"
android:paddingBottom="@dimen/small_spacing">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical"
android:layout_marginEnd="44dp">
<TextView
android:id="@+id/sub_scaling_Item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_scaling_image_view"
android:textColor="@color/md_dark_background"
android:textSize="@dimen/medium_text" />
<TextView
android:id="@+id/sub_scaling_Item_sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_scaling_image_view_sub"
android:textColor="@color/md_grey_400"
android:textSize="@dimen/sub_medium_text" />
</LinearLayout>
<android.support.v7.widget.SwitchCompat
android:id="@+id/sw_sub_scaling"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:button="@null"
android:hapticFeedbackEnabled="true"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>

<!-- USE MEDIA STORE -->

<LinearLayout
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/preferences-key.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
<string name="preference_use_password_on_delete">password_on_delete</string>
<string name="preference_internal_uri_extsdcard_photos">uri_extsdcard_photos</string>
<string name="preference_show_fab">show_fab</string>
<string name="preference_sub_scaling">use_sub_scaling</string>
</resources>
Loading

0 comments on commit 6babaad

Please sign in to comment.