Commit ac66ec3f authored by Gilbert Ndresaj's avatar Gilbert Ndresaj

Third Activity Update(#1)

Third Activity Update(#1)
parent 937de386
package com.leafpic.app.Base;
import android.content.Context;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.util.Log;
import com.leafpic.app.utils.StringUtils;
import java.io.File;
import java.util.ArrayList;
......@@ -231,4 +235,31 @@ public class HandlingPhotos implements Parcelable {
dest.writeByte((byte) (hidden ? 0x01 : 0x00));
}
public void renamePhoto(String olderPath, String name){
try {
File from = new File(olderPath);
File to = new File(StringUtils.getAlbumPathRenamed(olderPath, name));
String s[] = from.list(), dirPath = from.getAbsolutePath();
for (String paht : s) scanFile(new String[]{dirPath + "/" + paht});
from.renameTo(to);
s = to.list();
dirPath = to.getAbsolutePath();
for (String paht : s) scanFile(new String[]{dirPath + "/" + paht});
} catch (Exception e) {
e.printStackTrace();
}
}
public void scanFile(String[] path) {
MediaScannerConnection.scanFile(context, path, null, new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
System.out.println("SCAN COMPLETED: " + path);
}
});
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.leafpic.app.Adapters.PhotosPagerAdapter;
......@@ -20,6 +21,8 @@ import com.leafpic.app.Animations.DepthPageTransformer;
import com.leafpic.app.Base.HandlingPhotos;
import com.leafpic.app.utils.StringUtils;
import java.util.Calendar;
/**
* Created by dnld on 12/12/15.
*/
......@@ -37,6 +40,8 @@ public class PhotoActivity extends AppCompatActivity {
setContentView(R.layout.activity_photo);
initUiTweaks();
try {
Bundle data = getIntent().getExtras();
photos = data.getParcelable("album");
photos.setContext(PhotoActivity.this);
......@@ -113,9 +118,6 @@ public class PhotoActivity extends AppCompatActivity {
.show();
return true;
case R.id.rotatePhoto:
return true;
case R.id.useAsIntent:
String file_path_use_as = photos.photos.get(mViewPager.getCurrentItem()).Path;
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
......@@ -124,11 +126,74 @@ public class PhotoActivity extends AppCompatActivity {
startActivity(Intent.createChooser(intent, "Use As"));
return true;
case R.id.rotateSX:
return true;
case R.id.rotateDX:
return true;
case R.id.rotate180:
return true;
case R.id.renamePhoto:
/*
new MaterialDialog.Builder(this)
.title("Rename Photo")
.inputType(InputType.TYPE_CLASS_TEXT)
.input(null, StringUtils.getPhotoNamebyPath(photos.getCurrentPhoto().Path), new MaterialDialog.InputCallback() {
@Override
public void onInput(MaterialDialog dialog, CharSequence input) {
albums.renameAlbum(photos.FolderPath, input.toString());
//onBackPressed();
//finish();
StringUtils.showToast(getApplicationContext(), "I have to fix this!");
}
}).show();
*/
break;
case R.id.Modify:
break;
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 = "" + cl.get(Calendar.DAY_OF_MONTH) + "/" + cl.get(Calendar.MONTH) + "/" + cl.get(Calendar.YEAR);
String time = "" + cl.get(Calendar.HOUR_OF_DAY) + ":" + cl.get(Calendar.MINUTE) + ":" + cl.get(Calendar.SECOND);
/**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)
.title("Photo Details")
//.titleColor(color)
.content("Album: " + StringUtils.getPhotoNamebyPath(photos.FolderPath)
+ "\nName: " + StringUtils.getPhotoNamebyPath(photos.getCurrentPhoto().Path)
+ "\nDimensione: " + "DA Implementare"
+ "\nRisoluzione: " + "DA Implementare"
+ "\nFormato: " + photos.getCurrentPhoto().MIME
+ "\nData: " + date + " " + time)
.positiveText("OK")
.show();
break;
case R.id.setting:
Intent intent2= new Intent(PhotoActivity.this, SettingsActivity.class);
startActivity(intent2);
break;
default:
// If we got here, the user's action was not recognized.
// Invoke the superclass to handle it.
return super.onOptionsItemSelected(item);
//return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}
public void initUiTweaks() {
......
......@@ -8,29 +8,60 @@
<!-- Albums Stuff -->
<item
android:id="@+id/shareButton"
android:icon="@mipmap/ic_share_white_24dp"
android:title="Share"
app:showAsAction="always"
android:id="@+id/shareButton"
android:icon="@mipmap/ic_share_white_24dp"
android:title="Share"
app:showAsAction="always"
/>
<item
android:id="@+id/deletePhoto"
android:icon="@mipmap/ic_delete_white_24dp"
android:title="@string/delete_album_action"
app:showAsAction="always"
android:id="@+id/deletePhoto"
android:icon="@mipmap/ic_delete_white_24dp"
android:title="@string/delete_album_action"
app:showAsAction="always"
/>
<item
android:id="@+id/useAsIntent"
android:title="Use as"
app:showAsAction="never"
android:id="@+id/rotatePhoto"
android:icon="@mipmap/ic_rotate_right_white_24dp"
android:title="Rotate"
app:showAsAction="ifRoom">
<menu>
<item
android:id="@+id/rotateDX"
android:title="Rotate DX" />
<item
android:id="@+id/rotateSX"
android:title="Rotate SX" />
<item
android:id="@+id/rotate180"
android:title="Rotate 180" />
</menu>
</item>
<item
android:id="@+id/useAsIntent"
android:title="Use as"
app:showAsAction="never"
/>
<item
android:id="@+id/rotatePhoto"
android:icon="@mipmap/ic_rotate_right_white_24dp"
android:title="Rotate 90"
app:showAsAction="ifRoom"
android:id="@+id/Modify"
android:title="Modify"
app:showAsAction="never"
/>
<item
android:id="@+id/renamePhoto"
android:title="Rename"
app:showAsAction="never"
/>
<item
android:id="@+id/details"
android:title="Details"
app:showAsAction="never"
/>
<item
android:id="@+id/setting"
android:title="Setting"
app:showAsAction="never"
/>
<!-- End Albums Stuff -->
</menu>
\ No newline at end of file
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