Commit 7562b0f4 authored by Donald's avatar Donald

improved rename photo

decreased photos corruption
clean
fucked jibe's mum
parent 9e515bf8
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
<activity android:name=".SettingsActivity" <activity android:name=".SettingsActivity"
android:label="Setting" android:label="Setting"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:theme="@style/Theme.AppCompat.NoActionBar"
> >
</activity> </activity>
<activity android:name=".AlbumsActivity" <activity android:name=".AlbumsActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:theme="@style/Theme.AppCompat.NoActionBar"
> >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<activity android:name=".PhotosActivity" <activity android:name=".PhotosActivity"
android:label="Album" android:label="Album"
android:parentActivityName=".AlbumsActivity" android:parentActivityName=".AlbumsActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:theme="@style/Theme.AppCompat.NoActionBar"
> >
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
......
...@@ -42,6 +42,7 @@ public class PhotosAdapter extends RecyclerView.Adapter<PhotosAdapter.ViewHolder ...@@ -42,6 +42,7 @@ public class PhotosAdapter extends RecyclerView.Adapter<PhotosAdapter.ViewHolder
public void onBindViewHolder(PhotosAdapter.ViewHolder holder, int position) { public void onBindViewHolder(PhotosAdapter.ViewHolder holder, int position) {
Photo f = photos.get(position); Photo f = photos.get(position);
Glide.clear(holder.imageView);//fix corruption
if (f.MIME.equals("image/gif")) { if (f.MIME.equals("image/gif")) {
Ion.with(holder.imageView.getContext()) Ion.with(holder.imageView.getContext())
......
...@@ -11,7 +11,6 @@ import android.support.v4.view.ViewPager; ...@@ -11,7 +11,6 @@ import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.InputType; import android.text.InputType;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
...@@ -27,7 +26,6 @@ import com.leafpic.app.utils.StringUtils; ...@@ -27,7 +26,6 @@ import com.leafpic.app.utils.StringUtils;
import java.sql.Time; import java.sql.Time;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
/** /**
* Created by dnld on 12/12/15. * Created by dnld on 12/12/15.
...@@ -46,8 +44,6 @@ public class PhotoActivity extends AppCompatActivity { ...@@ -46,8 +44,6 @@ public class PhotoActivity extends AppCompatActivity {
setContentView(R.layout.activity_photo); setContentView(R.layout.activity_photo);
initUiTweaks(); initUiTweaks();
try { try {
Bundle data = getIntent().getExtras(); Bundle data = getIntent().getExtras();
photos = data.getParcelable("album"); photos = data.getParcelable("album");
photos.setContext(PhotoActivity.this); photos.setContext(PhotoActivity.this);
...@@ -62,27 +58,6 @@ public class PhotoActivity extends AppCompatActivity { ...@@ -62,27 +58,6 @@ public class PhotoActivity extends AppCompatActivity {
mViewPager.setAdapter(mCustomPagerAdapter); mViewPager.setAdapter(mCustomPagerAdapter);
mViewPager.setCurrentItem(photos.getCurrentPhotoIndex()); mViewPager.setCurrentItem(photos.getCurrentPhotoIndex());
Photo f = photos.getCurrentPhoto();
String[] projection = new String[]{
MediaStore.Images.Media.DATE_TAKEN,
MediaStore.Images.Media.DATA,
MediaStore.Images.Media.MIME_TYPE
};
Log.wtf("asdasdasd", f.Path);
Cursor cursor = getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection,
MediaStore.Images.Media.DATA + " = ?",
new String[]{f.Path}, "");
if (cursor.moveToFirst()) {
int columnIndex = cursor.getColumnIndex(MediaStore.Images.Media.MIME_TYPE);
StringUtils.showToast(getApplicationContext(), cursor.getString(columnIndex));
}
cursor.close();
mViewPager.setPageTransformer(true, new DepthPageTransformer()); mViewPager.setPageTransformer(true, new DepthPageTransformer());
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override @Override
...@@ -164,14 +139,16 @@ public class PhotoActivity extends AppCompatActivity { ...@@ -164,14 +139,16 @@ public class PhotoActivity extends AppCompatActivity {
return true; return true;
case R.id.renamePhoto: case R.id.renamePhoto:
new MaterialDialog.Builder(this) new MaterialDialog.Builder(this)
.title("Rename Photo") .title("Rename Photo")
.inputType(InputType.TYPE_CLASS_TEXT) .inputType(InputType.TYPE_CLASS_TEXT)
.input(null, StringUtils.getPhotoNamebyPath(photos.getCurrentPhoto().Path), new MaterialDialog.InputCallback() { .input(null, StringUtils.getPhotoNamebyPath(photos.getCurrentPhoto().Path), new MaterialDialog.InputCallback() {
@Override @Override
public void onInput(MaterialDialog dialog, CharSequence input) { public void onInput(MaterialDialog dialog, CharSequence input) {
photos.renamePhoto(photos.getCurrentPhoto().Path, String.valueOf(input)); photos.renamePhoto(
// StringUtils.showToast(getApplicationContext(), "I have to fix this!"); photos.getCurrentPhoto().Path,
input + StringUtils.getPhotoExtensionbyPath(photos.getCurrentPhoto().Path));
} }
}).show(); }).show();
...@@ -179,16 +156,10 @@ public class PhotoActivity extends AppCompatActivity { ...@@ -179,16 +156,10 @@ public class PhotoActivity extends AppCompatActivity {
case R.id.Modify: case R.id.Modify:
break; break;
case R.id.details: case R.id.details:
/****DATA****/
Calendar cl = Calendar.getInstance();
cl.setTimeInMillis(Long.parseLong(StringUtils.getPhotoNamebyPath(photos.getCurrentPhoto().DateTaken))); //here your time in miliseconds
String date = "", size = "", resolution = "";
SimpleDateFormat s = new SimpleDateFormat("dd/mm/yyyy HH:MM");// //new DateFormat();
date = s.format(new Time(Long.valueOf(photos.getCurrentPhoto().DateTaken)));
Photo f = photos.getCurrentPhoto(); Photo f = photos.getCurrentPhoto();
String date = "", size = "", resolution = "";
SimpleDateFormat s = new SimpleDateFormat("dd/mm/yyyy HH:MM");
date = s.format(new Time(Long.valueOf(f.DateTaken)));
String[] projection = new String[]{ String[] projection = new String[]{
MediaStore.Images.Media.SIZE, MediaStore.Images.Media.SIZE,
...@@ -209,26 +180,14 @@ public class PhotoActivity extends AppCompatActivity { ...@@ -209,26 +180,14 @@ public class PhotoActivity extends AppCompatActivity {
} }
cursor.close(); cursor.close();
/**GET COLOR**/
/*
SharedPreferences SP;
SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String SColor = SP.getString("PrefColor", "#03A9F4");
int color = Color.parseColor(SColor);
//Html.fromHtml("<b><font color='" + SColor + "'>" + "Dimensionedddd: " + "</font></b>" + "Ddddda Implementare");
*/
/**DIALOG**/
new MaterialDialog.Builder(this) new MaterialDialog.Builder(this)
.title("Photo Details") .title("Photo Details")
//.titleColor(color) .content("Path: \t" + photos.getCurrentPhoto().Path
.content("Album: " + StringUtils.getPhotoNamebyPath(photos.FolderPath) + "\nSize: \t" + size
+ "\nName: " + StringUtils.getPhotoNamebyPath(photos.getCurrentPhoto().Path) + "\nResolution: \t" + resolution
+ "\nDimensione: " + size + "\nType: \t" + photos.getCurrentPhoto().MIME
+ "\nRisoluzione: " + resolution + "\nDate: \t" + date)
+ "\nFormato: " + photos.getCurrentPhoto().MIME .positiveText("DONE")
+ "\nData: " + date)
.positiveText("OK")
.show(); .show();
break; break;
......
...@@ -30,7 +30,14 @@ public class StringUtils { ...@@ -30,7 +30,14 @@ public class StringUtils {
public static String getPhotoNamebyPath(String path) { public static String getPhotoNamebyPath(String path) {
String b[] = path.split("/"); String b[] = path.split("/");
return b[b.length - 1]; String fi = b[b.length - 1];
return fi.substring(0, fi.indexOf('.'));
}
public static String getPhotoExtensionbyPath(String path) {
String b[] = path.split("/");
String fi = b[b.length - 1];
return fi.substring(fi.indexOf('.'), fi.length());
} }
public static String getPhotoPathByFolderPathAndName(String folderPath, String name) { public static String getPhotoPathByFolderPathAndName(String folderPath, String name) {
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:theme="@style/Theme.AppCompat.NoActionBar" android:theme="@style/Theme.AppCompat.NoActionBar"
android:background="@color/background_material_dark"> android:background="@color/background_material_dark">
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout" android:id="@+id/app_bar_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true" android:fitsSystemWindows="true">
>
<android.support.design.widget.CollapsingToolbarLayout <android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar" android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -22,39 +23,24 @@ ...@@ -22,39 +23,24 @@
app:contentScrim="?attr/colorPrimary" app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp" app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp" app:expandedTitleMarginEnd="64dp"
android:fitsSystemWindows="true" android:fitsSystemWindows="true">
>
<!--COL WRAP CONTENT(SU HEIGHT) NON FUNGE DIO CANE-->
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" app:layout_collapseMode="parallax">
>
<ImageView <ImageView
android:id="@+id/image" android:id="@+id/image"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="250dp" android:layout_height="250dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"/>
/>
<!--COL WRAP CONTENT(SU HEIGHT) NON FUNGE DIO CANE-->
<!--
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/pic2"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
>
<TextView <TextView
android:id="@+id/AlbumName" android:id="@+id/AlbumName"
...@@ -65,16 +51,14 @@ ...@@ -65,16 +51,14 @@
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="30sp" android:textSize="30sp"/>
/>
<View <View
android:id="@+id/divider" android:id="@+id/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="2dp" android:layout_height="2dp"
android:background="@android:color/white" android:background="@android:color/white"
android:layout_marginStart="60dp" android:layout_marginStart="60dp"
android:layout_marginEnd="60dp" android:layout_marginEnd="60dp"/>
/>
<TextView <TextView
android:id="@+id/AlbumNPhotos" android:id="@+id/AlbumNPhotos"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -84,8 +68,7 @@ ...@@ -84,8 +68,7 @@
android:layout_marginBottom="70dp" android:layout_marginBottom="70dp"
android:maxLines="1" android:maxLines="1"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textSize="16sp" android:textSize="16sp"/>
/>
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
...@@ -96,7 +79,6 @@ ...@@ -96,7 +79,6 @@
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
/> />
<!--android:background="@color/trasparent_toolbar"-->
</android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
...@@ -108,7 +90,6 @@ ...@@ -108,7 +90,6 @@
android:layout_margin="2dp" android:layout_margin="2dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
> >
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -116,23 +97,17 @@ ...@@ -116,23 +97,17 @@
android:clipToPadding="false" android:clipToPadding="false"
android:background="@color/md_dark_background" android:background="@color/md_dark_background"
/> />
<!--app:layout_behavior="@StringUtils/appbar_scrolling_view_behavior"-->
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
<android.support.design.widget.FloatingActionButton <android.support.design.widget.FloatingActionButton
android:id="@+id/fab" android:id="@+id/fab"
android:onClick="fabClicked" android:onClick="fabClicked"
style="@style/fab" style="@style/fab"
app:theme="@style/ThemeOverlay.AppCompat.Light" android:theme="@style/ThemeOverlay.AppCompat.Light"
app:borderWidth="0dp" app:borderWidth="0dp"
app:elevation="4dp" app:elevation="4dp"
android:layout_margin="16dp" android:layout_margin="16dp"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|right"/> android:layout_gravity="bottom|right"/>
<!--
app:layout_anchor="@id/app_bar_layout"
app:layout_anchorGravity="bottom|right"
-->
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout <FrameLayout
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="wrap_content" android:layout_height="120dp"
android:layout_margin="2dp" android:layout_margin="2dp"
> >
<ImageView <ImageView
...@@ -37,8 +35,7 @@ ...@@ -37,8 +35,7 @@
<ImageView <ImageView
android:id="@+id/pic" android:id="@+id/pic"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:minHeight="120dp" android:scaleType="centerCrop"
android:scaleType="center"
/> />
</FrameLayout> </FrameLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment