diff --git a/.cproject b/.cproject index 28fe6c0f..40c91f79 100755 --- a/.cproject +++ b/.cproject @@ -33,7 +33,6 @@ - diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 00e4c4a5..adcc2800 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -43,6 +43,10 @@ + + @@ -220,9 +224,6 @@ - diff --git a/jni/Application.mk b/jni/Application.mk index f4866bb5..4fe0e08a 100755 --- a/jni/Application.mk +++ b/jni/Application.mk @@ -1,10 +1,10 @@ -APP_ABI := armeabi-v7a +#APP_ABI := armeabi-v7a #APP_ABI := x86 #unlocked -#APP_ABI := armeabi-v7a x86 +APP_ABI := armeabi-v7a x86 APP_STL := gnustl_static APP_OPTIM := release APP_PLATFORM := android-21 -NDK_TOOLCHAIN_VERSION=4.9 \ No newline at end of file +NDK_TOOLCHAIN_VERSION=4.9 diff --git a/libs/openiab-0.9.8.6.jar b/libs/openiab-0.9.8.7.jar similarity index 68% rename from libs/openiab-0.9.8.6.jar rename to libs/openiab-0.9.8.7.jar index 86c5691b..c9b160e2 100644 Binary files a/libs/openiab-0.9.8.6.jar and b/libs/openiab-0.9.8.7.jar differ diff --git a/res/xml/preferences_capture_panoramaaugmented_more.xml b/res/xml/preferences_capture_panoramaaugmented_more.xml index d4dcdbd2..53b73292 100755 --- a/res/xml/preferences_capture_panoramaaugmented_more.xml +++ b/res/xml/preferences_capture_panoramaaugmented_more.xml @@ -17,10 +17,11 @@ android:defaultValue="false" android:summary="@string/pref_plugin_capture_panoramaaugmented_memory_summary" android:key="pref_plugin_capture_panoramaaugmented_memory" /> + \ No newline at end of file diff --git a/res/xml/preferences_general_more.xml b/res/xml/preferences_general_more.xml index 5f06ea9e..4530b22d 100755 --- a/res/xml/preferences_general_more.xml +++ b/res/xml/preferences_general_more.xml @@ -32,7 +32,7 @@ android:value="save_configuration"/> +++ --> - - \ No newline at end of file + diff --git a/res/xml/preferences_vf_common.xml b/res/xml/preferences_vf_common.xml index f3e26489..cfc9a7a3 100755 --- a/res/xml/preferences_vf_common.xml +++ b/res/xml/preferences_vf_common.xml @@ -11,7 +11,7 @@ -+++ --> \ No newline at end of file ++++ --> diff --git a/res/xml/preferences_vf_gyro.xml b/res/xml/preferences_vf_gyro.xml index 389f67b6..b99478c5 100755 --- a/res/xml/preferences_vf_gyro.xml +++ b/res/xml/preferences_vf_gyro.xml @@ -3,9 +3,10 @@ android:title="@string/Pref_ShowGyroVF" android:defaultValue="false" android:key="PrefGyroVF" /> - + \ No newline at end of file diff --git a/src/com/almalence/opencam/ApplicationInterface.java b/src/com/almalence/opencam/ApplicationInterface.java old mode 100644 new mode 100755 diff --git a/src/com/almalence/opencam/MainScreen.java b/src/com/almalence/opencam/MainScreen.java index d1ee1c00..179224e1 100755 --- a/src/com/almalence/opencam/MainScreen.java +++ b/src/com/almalence/opencam/MainScreen.java @@ -100,7 +100,6 @@ Portions created by Initial Developer are Copyright (C) 2013 import com.almalence.opencam.ui.AlmalenceGUI; import com.almalence.opencam.ui.GLLayer; import com.almalence.opencam.ui.GUI; -import com.almalence.util.AppRater; //-+- --> /* + + try { - unlockAllSubscriptionYear = prefs.getBoolean("subscription_unlock_all_year", false); - } - if (true == prefs.contains("plugin_almalence_super")) + cameraController = CameraController.getInstance(); + } catch (VerifyError exp) { - superPurchased = prefs.getBoolean("plugin_almalence_super", false); + Log.e("MainScreen", exp.getMessage()); } - if (!unlockAllPurchased) - createBillingHandler(); - - /**** Billing *****/ - - // application rating helper - AppRater.app_launched(this); - // -+- --> - - keepScreenOn = prefs.getBoolean(sKeepScreenOn, false); + keepScreenOn = prefs.getBoolean(sKeepScreenOn, true); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); mWifiHandler = new WifiHandler(this); @@ -448,25 +433,13 @@ protected void onApplicationResume() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); -// + //-+- --> isCameraConfiguring = false; @@ -675,11 +648,6 @@ protected void onApplicationDestroy() PluginManager.getInstance().onDestroy(); CameraController.onDestroy(); - // } @@ -711,7 +679,7 @@ private void updatePreferences() CameraController.getCameraIndex() == 0 ? sImageSizeMultishotBackPref : sImageSizeMultishotFrontPref, "-1")); - keepScreenOn = prefs.getBoolean(sKeepScreenOn, false); + keepScreenOn = prefs.getBoolean(sKeepScreenOn, true); } @@ -1627,13 +1595,6 @@ public boolean onKeyDownEvent(int keyCode, KeyEvent event) return true; // return false; @@ -1806,467 +1767,22 @@ public static boolean isShowStore() return showStore; } - /*******************************************************/ - /************************ Billing ************************/ // /************************ Billing ************************/ /*******************************************************/ - // - - // installing packages from play store - public static void callStoreInstall(Activity act, String id) - { - try - { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setData(Uri.parse("market://details?id=" + id)); - act.startActivity(intent); - } catch (ActivityNotFoundException e) - { - return; - } - } protected void resetOrSaveSettings() { diff --git a/src/com/almalence/opencam/ui/AlmalenceGUI.java b/src/com/almalence/opencam/ui/AlmalenceGUI.java index fdb6092a..54835802 100644 --- a/src/com/almalence/opencam/ui/AlmalenceGUI.java +++ b/src/com/almalence/opencam/ui/AlmalenceGUI.java @@ -102,7 +102,6 @@ Portions created by Initial Developer are Copyright (C) 2013 import com.almalence.ui.ShutterSwitch; import com.almalence.ui.ShutterSwitch.OnShutterCheckedListener; import com.almalence.ui.ShutterSwitch.OnShutterClickListener; -import com.almalence.util.AppEditorNotifier; import com.almalence.util.Util; // - final RelativeLayout pagerLayout = ((RelativeLayout) guiView.findViewById(R.id.viewPagerLayout)); pagerLayout.addView(viewPager); @@ -265,73 +248,8 @@ private void initStoreList() price.setText(R.string.already_unlocked); else { - if (MainScreen.getInstance().isCouponSale()) - { - price.setText(MainScreen.getInstance().titleUnlockAllCoupon); - ((ImageView) item.findViewById(R.id.storeSaleImage)).setVisibility(View.VISIBLE); - } else - { - price.setText(MainScreen.getInstance().titleUnlockAll); - if (bOnSale) - ((ImageView) item.findViewById(R.id.storeSaleImage)).setVisibility(View.VISIBLE); - } - } - break; - case 1: - // Super - icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_super)); - description.setText(MainScreen.getAppResources() - .getString(R.string.Pref_Upgrde_Super_Preference_Title)); - if (MainScreen.getInstance().isPurchasedSuper() || MainScreen.getInstance().isPurchasedAll()) - price.setText(R.string.already_unlocked); - else - { - if (CameraController.isSuperModePossible()) - price.setText(MainScreen.getInstance().titleUnlockSuper); - else - price.setText(MainScreen.getAppResources() - .getString(R.string.Pref_Upgrde_SuperNotSupported)); - } - break; - case 2: - // HDR - icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_hdr)); - description.setText(MainScreen.getAppResources() - .getString(R.string.Pref_Upgrde_HDR_Preference_Title)); - if (MainScreen.getInstance().isPurchasedHDR() || MainScreen.getInstance().isPurchasedAll()) - price.setText(R.string.already_unlocked); - else - price.setText(MainScreen.getInstance().titleUnlockHDR); - break; - case 3: - // Panorama - icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_panorama)); - description.setText(MainScreen.getAppResources() - .getString(R.string.Pref_Upgrde_Panorama_Preference_Title)); - if (MainScreen.getInstance().isPurchasedPanorama() || MainScreen.getInstance().isPurchasedAll()) - price.setText(R.string.already_unlocked); - else - price.setText(MainScreen.getInstance().titleUnlockPano); - break; - case 4: - // multishot - icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_moving)); - description.setText(MainScreen.getAppResources() - .getString(R.string.Pref_Upgrde_Moving_Preference_Title)); - if (MainScreen.getInstance().isPurchasedMultishots() || MainScreen.getInstance().isPurchasedAll()) - price.setText(R.string.already_unlocked); - else - price.setText(MainScreen.getInstance().titleUnlockMoving); - break; - case 5: - // Promo code - icon.setImageDrawable(MainScreen.getAppResources().getDrawable(R.drawable.store_promo)); - description.setText(MainScreen.getAppResources() - .getString(R.string.Pref_Upgrde_PromoCode_Preference_Title)); - if (MainScreen.getInstance().isPurchasedAll()) - price.setText(R.string.already_unlocked); - else price.setText(""); + } break; default: break; @@ -366,26 +284,6 @@ private void purchasePressed(View v) case 0:// unlock all MainScreen.getInstance().purchaseAll(); break; - case 1:// HDR - if (CameraController.isSuperModePossible()) - MainScreen.getInstance().purchaseSuper(); - else - Toast.makeText(MainScreen.getMainContext(), "Not supported", Toast.LENGTH_LONG).show(); - break; - case 2:// HDR - MainScreen.getInstance().purchaseHDR(); - break; - case 3:// Panorama - MainScreen.getInstance().purchasePanorama(); - break; - case 4:// multishot - MainScreen.getInstance().purchaseMultishot(); - break; - case 5:// Promo - if (!MainScreen.getInstance().isPurchasedAll()) - MainScreen.getInstance().enterPromo(); - break; - default: break; } diff --git a/src/com/almalence/opencam/ui/SelfTimerAndPhotoTimeLapse.java b/src/com/almalence/opencam/ui/SelfTimerAndPhotoTimeLapse.java index 01c90a9e..073c7ffb 100644 --- a/src/com/almalence/opencam/ui/SelfTimerAndPhotoTimeLapse.java +++ b/src/com/almalence/opencam/ui/SelfTimerAndPhotoTimeLapse.java @@ -44,7 +44,6 @@ Portions created by Initial Developer are Copyright (C) 2013 import android.widget.RelativeLayout; import android.widget.Switch; import android.widget.TextView; - import com.almalence.ui.RotateImageView; // - BarcodeStorageHelper.addBarcode(barcode); showBarcodeViewDialog(barcode); diff --git a/src/com/almalence/util/AppEditorNotifier.java b/src/com/almalence/util/AppEditorNotifier.java deleted file mode 100644 index cae678a6..00000000 --- a/src/com/almalence/util/AppEditorNotifier.java +++ /dev/null @@ -1,161 +0,0 @@ -/* -The contents of this file are subject to the Mozilla Public License -Version 1.1 (the "License"); you may not use this file except in -compliance with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is collection of files collectively known as Open Camera. - -The Initial Developer of the Original Code is Almalence Inc. -Portions created by Initial Developer are Copyright (C) 2013 -by Almalence Inc. All Rights Reserved. - */ - -package com.almalence.util; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.content.DialogInterface.OnCancelListener; -import android.content.SharedPreferences; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -// -/* */ - -public class AppEditorNotifier -{ - private static int DAYS_UNTIL_PROMPT = 10; - - public static void app_launched(Activity mContext) - { - } - - public static final boolean isABCEditorInstalled(Activity activity) - { - try - { - activity.getPackageManager().getInstallerPackageName("com.almalence.opencameditor"); - } catch (IllegalArgumentException e) - { - return false; - } - - return true; - } - - public static boolean showEditorNotifierDialogIfNeeded(final Activity mContext) - { - final SharedPreferences prefs = mContext.getSharedPreferences("appeditornotifier", 0); - // check if installed - if (isABCEditorInstalled(ApplicationScreen.instance)) - { - return false; - } - - DAYS_UNTIL_PROMPT = prefs.getInt("days_until_prompt", 10); - Long date_firstLaunch = prefs.getLong("date_firstlaunch_editornotifier", 0); - if (date_firstLaunch == 0) - { - date_firstLaunch = System.currentTimeMillis(); - prefs.edit().putLong("date_firstlaunch_editornotifier", date_firstLaunch).commit(); - showEditorNotifierDialog(mContext, prefs); - return true; - } - - if (System.currentTimeMillis() < date_firstLaunch + Long.valueOf((long)DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000)) - { - ApplicationScreen.instance.guiManager.openGallery(true); - return true; - } - - showEditorNotifierDialog(mContext, prefs); - return true; - } - - private static void showEditorNotifierDialog(final Activity mContext, final SharedPreferences prefs) - { - final float density = mContext.getResources().getDisplayMetrics().density; - - LinearLayout ll = new LinearLayout(mContext); - ll.setOrientation(LinearLayout.VERTICAL); - ll.setPadding((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density)); - - ImageView img = new ImageView(mContext); - img.setImageDrawable(ApplicationScreen.getAppResources().getDrawable(R.drawable.editor_adv)); - ll.addView(img); - - TextView tv = new TextView(mContext); - tv.setText(ApplicationScreen.getAppResources().getString(R.string.editorAdvText)); - tv.setWidth((int) (250 * density)); - tv.setPadding((int) (4 * density), 0, (int) (4 * density), (int) (24 * density)); - ll.addView(tv); - - Button bInstall = new Button(mContext); - bInstall.setText(ApplicationScreen.getAppResources().getString(R.string.editorInstallText)); - ll.addView(bInstall); - - Button bLater = new Button(mContext); - bLater.setText(ApplicationScreen.getAppResources().getString(R.string.editorNoText)); - ll.addView(bLater); - - final AlertDialog.Builder builder = new AlertDialog.Builder(mContext); - builder.setView(ll); - final AlertDialog dialog = builder.create(); - dialog.setOnCancelListener(new OnCancelListener() - { - @Override - public void onCancel(DialogInterface dialog) - { - ApplicationScreen.instance.guiManager.openGallery(true); - } - }); - - bInstall.setOnClickListener(new OnClickListener() - { - public void onClick(View v) - { - MainScreen.callStoreInstall(mContext, "com.almalence.opencameditor"); - prefs.edit().putInt("days_until_prompt", 999).commit(); - dialog.dismiss(); - } - }); - - bLater.setOnClickListener(new OnClickListener() - { - public void onClick(View v) - { - dialog.dismiss(); - ApplicationScreen.instance.guiManager.openGallery(true); - - if (DAYS_UNTIL_PROMPT <= 10) - DAYS_UNTIL_PROMPT = 30; - else if (DAYS_UNTIL_PROMPT == 30) - DAYS_UNTIL_PROMPT = 999; - - prefs.edit().putInt("days_until_prompt", DAYS_UNTIL_PROMPT).commit(); - } - }); - - dialog.show(); - } -} diff --git a/src/com/almalence/util/AppRater.java b/src/com/almalence/util/AppRater.java deleted file mode 100755 index 88809750..00000000 --- a/src/com/almalence/util/AppRater.java +++ /dev/null @@ -1,243 +0,0 @@ -/* -The contents of this file are subject to the Mozilla Public License -Version 1.1 (the "License"); you may not use this file except in -compliance with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is collection of files collectively known as Open Camera. - -The Initial Developer of the Original Code is Almalence Inc. -Portions created by Initial Developer are Copyright (C) 2013 -by Almalence Inc. All Rights Reserved. - */ - -package com.almalence.util; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.content.DialogInterface.OnCancelListener; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.graphics.drawable.LayerDrawable; -import android.graphics.PorterDuff; -import android.net.Uri; -import android.os.Build; -import android.view.Gravity; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup.LayoutParams; -import android.widget.Button; -import android.widget.LinearLayout; -import android.widget.RatingBar; -import android.widget.TextView; - -import com.almalence.opencam.ApplicationScreen; -import com.almalence.opencam.MainScreen; -import com.almalence.opencam.R; - -public class AppRater -{ - private static final int DAYS_UNTIL_PROMPT = 0; - private static final int LAUNCHES_UNTIL_PROMPT = 15; - - public static void app_launched(Activity mContext) - { - SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0); - if (prefs.getBoolean("dontshowagain", false)) - { - return; - } - - SharedPreferences.Editor editor = prefs.edit(); - - // Increment launch counter - long launch_count = prefs.getLong("launch_count", 0) + 1; - editor.putLong("launch_count", launch_count); - - // Get date of first launch - Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0); - if (date_firstLaunch == 0) - { - date_firstLaunch = System.currentTimeMillis(); - editor.putLong("date_firstlaunch", date_firstLaunch); - } - - editor.commit(); - } - - public static boolean showRateDialogIfNeeded(final Activity mContext) - { - // temp research - disable rater for 4.03 - 4.0.4 - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) - return false; - - final SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0); - if (prefs.getBoolean("dontshowagain", false)) - { - return false; - } - - final long launch_count = prefs.getLong("launch_count", 0) + 1; - final Long date_firstLaunch = prefs.getLong("date_firstlaunch", 0); - - if (launch_count >= LAUNCHES_UNTIL_PROMPT) - { - if (System.currentTimeMillis() >= date_firstLaunch + Long.valueOf((long)DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000)) - { - showRateDialog(mContext, prefs); - - return true; - } - } - - return false; - } - - private static void showRateDialog(final Activity mContext, final SharedPreferences prefs) - { - final float density = mContext.getResources().getDisplayMetrics().density; - - LinearLayout ll = new LinearLayout(mContext); - ll.setOrientation(LinearLayout.VERTICAL); - ll.setPadding((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density)); - - TextView tv = new TextView(mContext); - tv.setText(mContext.getResources().getString(R.string.raterMain)); - tv.setWidth((int) (250 * density)); - tv.setPadding((int) (4 * density), 0, (int) (4 * density), (int) (24 * density)); - ll.addView(tv); - - // rating bar - final RatingBar ratingBar = new RatingBar(mContext); - ratingBar.setNumStars(5); - ratingBar.setStepSize(1); - LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable(); - stars.getDrawable(0).setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_ATOP); - stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, - LayoutParams.WRAP_CONTENT); - params.gravity = Gravity.CENTER_HORIZONTAL; - params.setMargins(0, 5, 0, 10); - ratingBar.setLayoutParams(params); - ll.addView(ratingBar); - - Button b3 = new Button(mContext); - b3.setText(mContext.getResources().getString(R.string.raterNo)); - ll.addView(b3); - - final AlertDialog.Builder builder = new AlertDialog.Builder(mContext); - builder.setView(ll); - final AlertDialog dialog = builder.create(); - dialog.setOnCancelListener(new OnCancelListener() - { - @Override - public void onCancel(DialogInterface dialog) - { - mContext.finish(); - } - }); - - ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() - { - public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) - { - if (prefs != null) - { - prefs.edit().putBoolean("dontshowagain", true).commit(); - } - dialog.dismiss(); - - if (rating >= 4) - { - mContext.finish(); - MainScreen.callStoreFree(mContext); - } else - contactSupport(); - } - }); - - b3.setOnClickListener(new OnClickListener() - { - public void onClick(View v) - { - if (prefs != null) - { - prefs.edit().putBoolean("dontshowagain", true).commit(); - mContext.finish(); - } - - dialog.dismiss(); - } - }); - - dialog.show(); - } - - private static void contactSupport() - { - final float density = ApplicationScreen.getAppResources().getDisplayMetrics().density; - - LinearLayout ll = new LinearLayout(ApplicationScreen.instance); - ll.setOrientation(LinearLayout.VERTICAL); - ll.setPadding((int) (10 * density), (int) (10 * density), (int) (10 * density), (int) (10 * density)); - - TextView tv = new TextView(ApplicationScreen.instance); - tv.setText(ApplicationScreen.getAppResources().getString(R.string.raterSendReview)); - tv.setWidth((int) (250 * density)); - tv.setPadding((int) (4 * density), 0, (int) (4 * density), (int) (24 * density)); - ll.addView(tv); - - Button b1 = new Button(ApplicationScreen.instance); - b1.setText(ApplicationScreen.getAppResources().getString(R.string.raterSend)); - ll.addView(b1); - - Button b2 = new Button(ApplicationScreen.instance); - b2.setText(ApplicationScreen.getAppResources().getString(R.string.raterNo)); - ll.addView(b2); - - final AlertDialog.Builder builder = new AlertDialog.Builder(ApplicationScreen.instance); - builder.setView(ll); - final AlertDialog dialog = builder.create(); - dialog.setOnCancelListener(new OnCancelListener() - { - @Override - public void onCancel(DialogInterface dialog) - { - ApplicationScreen.instance.finish(); - } - }); - - b1.setOnClickListener(new OnClickListener() - { - public void onClick(View v) - { - Intent intent = new Intent(Intent.ACTION_SENDTO); - intent.setType("message/rfc822"); - intent.putExtra(Intent.EXTRA_SUBJECT, "A Better Camera inapp review"); - intent.setData(Uri.parse("mailto:support@abc.almalence.com")); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - ApplicationScreen.instance.startActivity(intent); - dialog.dismiss(); - ApplicationScreen.instance.finish(); - } - }); - b2.setOnClickListener(new OnClickListener() - { - public void onClick(View v) - { - dialog.dismiss(); - ApplicationScreen.instance.finish(); - } - }); - dialog.show(); - } - -} \ No newline at end of file diff --git a/src/com/almalence/util/Util.java b/src/com/almalence/util/Util.java index 7a381743..68a24fad 100755 --- a/src/com/almalence/util/Util.java +++ b/src/com/almalence/util/Util.java @@ -913,48 +913,6 @@ public static File getFileFromDocumentFile(DocumentFile documentFile) } } - -// public static String getAbsolutePathFromDocumentFile(DocumentFile documentFile) -// { -// // We can't get absolute path from DocumentFile or Uri. -// // It is a hack to build absolute path by DocumentFile. -// // May not work on some devices. -// Uri uri = documentFile.getUri(); -// final String docId = DocumentsContract.getDocumentId(uri); -// final String[] split = docId.split(":"); -// final String id = split[1]; -// -// String sd = null; -// sd = System.getenv("SECONDARY_STORAGE"); -// if (sd == null) -// { -// sd = System.getenv("EXTERNAL_STORAGE"); -// } -// -// if (sd != null) -// { -// // On some devices SECONDARY_STORAGE has several paths -// // separated with a colon (":"). This is why we split -// // the String. -// String[] paths = sd.split(":"); -// for (String p : paths) -// { -// File fileSD = new File(p); -// if (fileSD.isDirectory()) -// { -// sd = fileSD.getAbsolutePath(); -// } -// } -// -// String documentPath = sd + "/" + id; -// return documentPath; -// } -// return null; -// } - - - // Get File absolute path from DocumentFile object. - // This method should be used only for files saved to SD-card. public static String getAbsolutePathFromDocumentFile(DocumentFile documentFile) { // We can't get absolute path from DocumentFile or Uri. @@ -974,6 +932,7 @@ public static String getAbsolutePathFromDocumentFile(DocumentFile documentFile) String documentPath = "/storage" + "/" + docId.replace(":", "/"); return documentPath; } + if (sd != null) { // On some devices SECONDARY_STORAGE has several paths @@ -994,6 +953,47 @@ public static String getAbsolutePathFromDocumentFile(DocumentFile documentFile) } return null; } + +// // Get File absolute path from DocumentFile object. +// // This method should be used only for files saved to SD-card. +// public static String getAbsolutePathFromDocumentFile(DocumentFile documentFile) +// { +// // We can't get absolute path from DocumentFile or Uri. +// // It is a hack to build absolute path by DocumentFile. +// // May not work on some devices. +// Uri uri = documentFile.getUri(); +// final String docId = DocumentsContract.getDocumentId(uri); +// final String[] split = docId.split(":"); +// final String id = split[1]; +// +// String sd = null; +// sd = System.getenv("SECONDARY_STORAGE"); +// if (sd == null) +// { +//// sd = System.getenv("EXTERNAL_STORAGE"); +// String documentPath = "/storage" + "/" + docId.replace(":", "/"); +// return documentPath; +// } +// if (sd != null) +// { +// // On some devices SECONDARY_STORAGE has several paths +// // separated with a colon (":"). This is why we split +// // the String. +// String[] paths = sd.split(":"); +// for (String p : paths) +// { +// File fileSD = new File(p); +// if (fileSD.isDirectory()) +// { +// sd = fileSD.getAbsolutePath(); +// } +// } +// +// String documentPath = sd + "/" + id; +// return documentPath; +// } +// return null; +// } public static int getMaxImageSizeIndex(android.util.Size[] ImageSizes) { int maxSizeIndex = 0;