├── .gitignore ├── IMG_3055.jpg ├── IMG_3056.jpg ├── README.md ├── app ├── .DS_Store ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── release │ └── app-release.aab └── src │ ├── androidTest │ └── java │ │ └── proj │ │ └── me │ │ └── bitframedemo │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── proj │ │ └── me │ │ └── bitframedemo │ │ ├── BaseActivity.java │ │ ├── BindingAddText.java │ │ ├── CustomAdapter_Dialog.java │ │ ├── CustomDialogFrag.java │ │ ├── FrameActivity.java │ │ ├── FrameRecyclerActivity.java │ │ ├── ImageIntent.java │ │ ├── IntentAction.java │ │ ├── ViewHolder_Dialog.java │ │ ├── adapter │ │ └── FrameAdapter.java │ │ ├── beans │ │ ├── BaseResponse.java │ │ ├── Bundle.java │ │ ├── BundleDetail.java │ │ ├── FrameBean.java │ │ ├── FrameResponse.java │ │ ├── NextBundle.java │ │ └── UploadRequest.java │ │ ├── binders │ │ ├── CardBinder.java │ │ └── FrameBinder.java │ │ ├── broadcasts │ │ ├── ConnectivityReceiver.java │ │ └── UploadReceiver.java │ │ ├── helper │ │ └── Constants.java │ │ ├── network │ │ ├── DownloadImpl.java │ │ ├── RetrofitClient.java │ │ ├── RetrofitImpl.java │ │ └── UploadImpl.java │ │ └── services │ │ └── UploadService.java │ └── res │ ├── drawable │ └── round_bg.xml │ ├── layout │ ├── activity_frame.xml │ ├── card_container.xml │ ├── custom_list.xml │ ├── custom_text.xml │ └── frame_recycler.xml │ ├── menu │ └── upload_menu.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── bitframe ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── proj │ │ └── me │ │ └── bitframe │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── proj │ │ │ └── me │ │ │ └── bitframe │ │ │ ├── BeanBitFrame.java │ │ │ ├── BeanHandler.java │ │ │ ├── BeanImage.java │ │ │ ├── BinadingBitFrame.java │ │ │ ├── FrameCallback.java │ │ │ ├── FrameHandler.java │ │ │ ├── FrameModel.java │ │ │ ├── ImageCallback.java │ │ │ ├── ImageClickHandler.java │ │ │ ├── ImageResult.java │ │ │ ├── ImageScrollParcelable.java │ │ │ ├── ImageShades.java │ │ │ ├── ImageShading.java │ │ │ ├── ImageType.java │ │ │ ├── PaletteListener.java │ │ │ ├── ScaleTransformation.java │ │ │ ├── UnframedLocalTask.java │ │ │ ├── UnframedPicassoTarget.java │ │ │ ├── UnframedPicassoTargetNew.java │ │ │ ├── ViewFrame.java │ │ │ ├── dimentions │ │ │ ├── BeanShade1.java │ │ │ ├── BeanShade2.java │ │ │ ├── BeanShade3.java │ │ │ ├── BeanShade4.java │ │ │ ├── ImageOrder.java │ │ │ └── LayoutType.java │ │ │ ├── exceptions │ │ │ └── FrameException.java │ │ │ ├── frames │ │ │ ├── AvailableTypes.java │ │ │ ├── FrameHelper.java │ │ │ ├── IndexQueue.java │ │ │ ├── Node.java │ │ │ └── tournament │ │ │ │ ├── FrameBuilder.java │ │ │ │ ├── FrameBundle.java │ │ │ │ ├── FrameTypeBuilder.java │ │ │ │ ├── FramedPictures.java │ │ │ │ ├── Picture.java │ │ │ │ ├── PictureAttribute.java │ │ │ │ ├── PictureFrame.java │ │ │ │ ├── RangeBar.java │ │ │ │ ├── TournamentType.java │ │ │ │ └── Utility.java │ │ │ ├── helper │ │ │ ├── BeanBitmapResult.java │ │ │ ├── BeanResult.java │ │ │ ├── ColorCombination.java │ │ │ ├── ColorPallet.java │ │ │ ├── FrameType.java │ │ │ └── Utils.java │ │ │ ├── shading_four │ │ │ ├── BindingShadeFour.java │ │ │ ├── ImageShadingFour.java │ │ │ └── ShadeFour.java │ │ │ ├── shading_one │ │ │ ├── BindingShadeOne.java │ │ │ ├── ImageShadingOne.java │ │ │ └── ShadeOne.java │ │ │ ├── shading_three │ │ │ ├── BindingShadeThree.java │ │ │ ├── ImageShadingThree.java │ │ │ └── ShadeThree.java │ │ │ └── shading_two │ │ │ ├── BindingShadeTwo.java │ │ │ ├── ImageShadingTwo.java │ │ │ └── ShadeTwo.java │ └── res │ │ ├── drawable │ │ └── ic_launcher.png │ │ ├── layout │ │ ├── item_imageview.xml │ │ ├── noscroll_item_imageview.xml │ │ ├── view_double_horz.xml │ │ ├── view_double_vert.xml │ │ ├── view_multiple_horz.xml │ │ ├── view_multiple_horz_double.xml │ │ ├── view_multiple_horz_vert.xml │ │ ├── view_multiple_vary_height.xml │ │ ├── view_multiple_vary_width.xml │ │ ├── view_multiple_vert.xml │ │ ├── view_multiple_vert_double.xml │ │ ├── view_multiple_vert_horz.xml │ │ ├── view_single.xml │ │ ├── view_tripple_horz.xml │ │ ├── view_tripple_parr_horz.xml │ │ ├── view_tripple_parr_vert.xml │ │ └── view_tripple_vert.xml │ │ ├── values-hdpi │ │ └── dimens.xml │ │ ├── values-xhdpi │ │ └── dimens.xml │ │ ├── values-xxhdpi │ │ └── dimens.xml │ │ └── values │ │ ├── attributes.xml │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── ids.xml │ │ └── strings.xml │ └── test │ └── java │ └── proj │ └── me │ └── bitframe │ ├── Dimension.java │ ├── DimensionsModel.java │ ├── MultiDimensionModel.java │ ├── shading_four │ └── ShadeFourTest.java │ ├── shading_three │ └── ShadeThreeTest.java │ └── shading_two │ └── ShadeTwoTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── licence.md └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | #idea files 20 | .idea/ 21 | 22 | #iml files 23 | *.iml 24 | 25 | # Local configuration file (sdk path, etc) 26 | local.properties 27 | 28 | # Proguard folder generated by Eclipse 29 | proguard/ 30 | 31 | # Log Files 32 | *.log 33 | 34 | # Android Studio Navigation editor temp files 35 | .navigation/ 36 | 37 | # Android Studio captures folder 38 | captures/ 39 | 40 | # Android Studio project backups 41 | projectFilesBackup/ 42 | 43 | .gradle 44 | /local.properties 45 | /.idea/caches 46 | /.idea/libraries 47 | /.idea/modules.xml 48 | /.idea/workspace.xml 49 | /.idea/navEditor.xml 50 | /.idea/assetWizardSettings.xml 51 | /.DS_Store 52 | /build 53 | /captures 54 | .externalNativeBuild 55 | .cxx 56 | /app/app.iml 57 | /bitframe/bitframe.iml -------------------------------------------------------------------------------- /IMG_3055.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/IMG_3055.jpg -------------------------------------------------------------------------------- /IMG_3056.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/IMG_3056.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BitFrames 2 | Frame of Bitmaps 3 | 4 | 5 | Get it on Google Play 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ![logo](https://github.com/deepaktwr/BitFrames/blob/master/IMG_3055.jpg) ![logo](https://github.com/deepaktwr/BitFrames/blob/master/IMG_3056.jpg) 14 | 15 | 16 | 17 | You may find a working implementation in /app 18 | 19 | 20 | ### Description 21 | ViewFrame takes set of image links (local or network based) and will frame them based on their dimensions.The container may contain 1, 2, 3 or max 4 images and they will occupy space based on their dimensions.The image count with greater than 4 will show the overflow number. 22 | 23 | You may shuffle and frames by setting different primary and secondary count values and setting 24 | ```xml 25 | frame:shouldSortImages 26 | ``` 27 | to true. 28 | 29 | Palette colors has been used to set background of the image.Inverse color and mixed color of all the images used to create divider color of the container 30 | 31 | 32 | # Usage 33 | 34 | 35 | ### Add a widget to the layout file- 36 | 37 | ```xml 38 | 42 | ``` 43 | 44 | 45 | by default the width and height has been set as 192 dp and 256 dp. 46 | 47 | ```xml 48 | frame:max_container_width="@dimen/d_192" 49 | frame:max_container_height="@dimen/d_256" 50 | ``` 51 | you may alter these or can set it from ViewFrame's method: 52 | 53 | ```java 54 | public void setFrameDimensions(float minFrameWidth, float minFrameHeight, float maxContainerWidth, float maxContainerHeight); 55 | ``` 56 | passing 0's to all will set width and height of the frame as 99.96% 0f widthPixelsOfDevice and same in height if it's not greater than widthPixelsOfDevice. 57 | 58 | 59 | ### Make frames based of local path or links to the images: 60 | 61 | ```java 62 | viewFrame.showBitFrame(beanImageList, callback, frameType); 63 | ``` 64 | 65 | ##### beanImageList : 66 | the list of image uris, comments, primary and secondary count. 67 | it can be a list of @BeanImages if you don't have image dimensions and colors otherwise you can pass @BeanBitFrame with dimensions and colors to the image to show palette* colors until they load. 68 | 69 | #### callback: 70 | gives you the all image dimensions , colors in that frame(you might ignore it and pass it null if you don't want any callback) 71 | it'll also provide you mixed and inverse colors to the framed images. 72 | 73 | #### frameType: 74 | Provide frame type of UNFRAMED if you are passing @BeanImages which don't have any image dimensions or colors 75 | otherwise pass FRAMED in case you are passing @BeanBitFrame with image dimensions and colors 76 | 77 | 78 | ### *_Attributes(optional):_* 79 | 80 | ```xml 81 | frame:minFrameWidth 82 | ``` 83 | the minimum width of the image in the frame(howevere it'll calculate it as per other images and their dimensions) 84 | 85 | ```xml 86 | frame:minFrameHeight 87 | ``` 88 | the minimum height to the image in the frame 89 | 90 | ```xml 91 | frame:maxContainerWidth 92 | ``` 93 | the frame width which will contain all images 94 | 95 | ```xml 96 | frame:maxContainerHeight 97 | ``` 98 | the frame height which will contain all images 99 | 100 | ```xml 101 | frame:maxFrameCount 102 | ``` 103 | the max frame count to show(it'll show +N if images exceeds that count) 104 | 105 | ```xml 106 | frame:isAddInLayout 107 | ``` 108 | you may provide add in the layout i.e if sapce remains then it'll show add a new image button in the container itself(you'll have it in callback) 109 | 110 | ```xml 111 | frame:minAddRatio 112 | ``` 113 | the add buton ratio with the images 114 | 115 | ```xml 116 | frame:shouldShowComment 117 | ``` 118 | you may provide comment to the image and pass this as true to show that 119 | 120 | ```xml 121 | frame:commentTransparencyPercent 122 | ``` 123 | it'll set the transparency of the comment background related to image between 1 to 100 124 | 125 | ```xml 126 | frame:hasScroll 127 | ``` 128 | shoud container has scroll as it's parent 129 | 130 | ```xml 131 | frame:hasFixedDimensions 132 | ``` 133 | if true, frame may varry it's width and height as image dimensions.(but always be within maxContainerWidth and maxContainerHeight) 134 | 135 | ```xml 136 | frame:shouldStoreImages 137 | ``` 138 | should cache the images when using picasso* 139 | 140 | ```xml 141 | frame:shouldRecycleBitmaps 142 | ``` 143 | if true, it'll recycle all the bitmaps after framing done 144 | 145 | ```xml 146 | frame:shouldSortImages 147 | ``` 148 | if true, it'll sort the image based on primary and secondary count provided 149 | 150 | ```xml 151 | frame:colorCombination 152 | ``` 153 | VIBRANT_TO_MUTED or MUTED_TO_VIBRANT i.e which color combination will be priorties to set background of the image 154 | 155 | ```xml 156 | frame:errorDrawable 157 | ``` 158 | in case image failed to load 159 | 160 | ```xml 161 | frame:imageScaleType 162 | ``` 163 | default is centerInside 164 | 165 | 166 | 167 | 168 | 169 | ## Include with android project as gradle dependency: 170 | 171 | ```code 172 | repositories { 173 | jcenter() 174 | } 175 | dependencies{ 176 | implementation 'com.github.deepaktwr:bitframe:2.3.0' 177 | } 178 | ``` 179 | -------------------------------------------------------------------------------- /app/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/app/.DS_Store -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 30 5 | buildToolsVersion "25.0.3" 6 | 7 | defaultConfig { 8 | applicationId "proj.me.bitframedemo" 9 | minSdkVersion 19 10 | targetSdkVersion 30 11 | versionCode 5 12 | versionName "1.4" 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | api project(":bitframe") 25 | api 'androidx.appcompat:appcompat:1.2.0' 26 | api 'com.squareup.retrofit2:retrofit:2.1.0' 27 | api 'com.squareup.retrofit2:converter-jackson:2.1.0' 28 | api 'androidx.recyclerview:recyclerview:1.1.0' 29 | api 'androidx.cardview:cardview:1.0.0' 30 | api 'com.google.android.material:material:1.2.1' 31 | 32 | } 33 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /media/deepak_t/mydrive/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/release/app-release.aab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/app/release/app-release.aab -------------------------------------------------------------------------------- /app/src/androidTest/java/proj/me/bitframedemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 18 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/BindingAddText.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo; 2 | 3 | import android.content.res.ColorStateList; 4 | import android.os.Build; 5 | import android.view.View; 6 | import android.widget.TextView; 7 | 8 | import com.google.android.material.floatingactionbutton.FloatingActionButton; 9 | 10 | /** 11 | * Created by root on 23/4/16. 12 | */ 13 | public class BindingAddText { 14 | private View root; 15 | 16 | View bind(View root, final IntentAction clickHandler) { 17 | this.root = root; 18 | 19 | root.findViewById(R.id.extra_text).setOnClickListener(new View.OnClickListener() { 20 | @Override 21 | public void onClick(View view) { 22 | clickHandler.addMoreImages(view); 23 | } 24 | }); 25 | 26 | return root; 27 | } 28 | 29 | public void setTextVisibility(boolean textVisibility) { 30 | FloatingActionButton floatingActionButton = root.findViewById(R.id.extra_text); 31 | floatingActionButton.setVisibility(textVisibility ? View.VISIBLE : View.GONE); 32 | } 33 | 34 | public void setTextColor(int textColor) { 35 | FloatingActionButton floatingActionButton = root.findViewById(R.id.extra_text); 36 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 37 | floatingActionButton.setImageTintList(ColorStateList.valueOf(textColor)); 38 | } else floatingActionButton.setSupportImageTintList(ColorStateList.valueOf(textColor)); 39 | } 40 | 41 | public void setErrorVisibility(boolean errorVisibility) { 42 | TextView textView = root.findViewById(R.id.error_text); 43 | textView.setVisibility(errorVisibility ? View.VISIBLE : View.GONE); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/CustomAdapter_Dialog.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.TextView; 9 | 10 | 11 | import java.util.ArrayList; 12 | 13 | import proj.me.bitframe.helper.Utils; 14 | 15 | 16 | public class CustomAdapter_Dialog extends BaseAdapter{ 17 | 18 | private ArrayList data; 19 | private Context context; 20 | private LayoutInflater inflater; 21 | private ViewHolder_Dialog holder; 22 | private int colorPosition; 23 | public CustomAdapter_Dialog(Context context,ArrayList data) 24 | { 25 | this.context=context; 26 | this.data=data; 27 | inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 28 | } 29 | public void setColorForPosition(int position){ 30 | colorPosition=position; 31 | notifyDataSetChanged();; 32 | } 33 | @Override 34 | public int getCount() { 35 | // TODO Auto-generated method stub 36 | return data.size(); 37 | } 38 | 39 | @Override 40 | public Object getItem(int position) { 41 | // TODO Auto-generated method stub 42 | return data.get(position); 43 | } 44 | 45 | @Override 46 | public long getItemId(int position) { 47 | // TODO Auto-generated method stub 48 | return 0; 49 | } 50 | 51 | @Override 52 | public View getView(int position, View convertView, ViewGroup parent) { 53 | // TODO Auto-generated method stub 54 | if(convertView==null) 55 | { 56 | holder=new ViewHolder_Dialog(); 57 | convertView=inflater.inflate(R.layout.custom_text, null); 58 | holder.text=(TextView) convertView.findViewById(R.id.dynamic_view_text); 59 | 60 | convertView.setTag(holder); 61 | 62 | } 63 | else 64 | holder=(ViewHolder_Dialog)convertView.getTag(); 65 | 66 | if( position == colorPosition ){ 67 | convertView.findViewById(R.id.ll_top_custom).setBackgroundColor(Utils.getVersionColor(context, 68 | R.color.title_of_selected_forms)); 69 | }else{ 70 | convertView.findViewById(R.id.ll_top_custom).setBackgroundColor(Utils.getVersionColor(context, 71 | R.color.white)); 72 | } 73 | holder.text.setText(data.get(position)); 74 | return convertView; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/CustomDialogFrag.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo; 2 | 3 | import java.util.ArrayList; 4 | 5 | import android.annotation.SuppressLint; 6 | import android.content.Context; 7 | import android.os.Bundle; 8 | import android.app.DialogFragment; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.view.Window; 13 | import android.widget.AdapterView; 14 | import android.widget.AdapterView.OnItemClickListener; 15 | import android.widget.ListView; 16 | 17 | 18 | 19 | @SuppressLint("ValidFragment") 20 | public class CustomDialogFrag extends DialogFragment 21 | { 22 | private View view = null; 23 | private ListView list = null; 24 | private Context context = null; 25 | private CustomAdapter_Dialog customAdapter = null; 26 | private ArrayList data = null; 27 | private ImageIntent imageIntent; 28 | 29 | public CustomDialogFrag(ImageIntent imageIntent) 30 | { 31 | this.imageIntent = imageIntent; 32 | } 33 | 34 | @Override 35 | public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) 36 | { 37 | view=inflater.inflate(R.layout.custom_list, container,false); 38 | getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); 39 | return view; 40 | } 41 | 42 | @Override 43 | public void onActivityCreated(Bundle arg0) 44 | { 45 | super.onActivityCreated(arg0); 46 | 47 | list=(ListView)view.findViewById(R.id.list); 48 | context=getActivity(); 49 | setDataImage(); 50 | 51 | customAdapter=new CustomAdapter_Dialog(context, data); 52 | list.setAdapter(customAdapter); 53 | 54 | list.setOnItemClickListener(new OnItemClickListener() { 55 | 56 | @Override 57 | public void onItemClick(AdapterView arg0, View arg1, int arg2, 58 | long arg3) { 59 | // TODO Auto-generated method stub 60 | setAction(arg2); 61 | } 62 | }); 63 | } 64 | 65 | 66 | private void setAction(int id) 67 | { 68 | if(id==0){ 69 | this.dismiss(); 70 | imageIntent.takePhoto(); 71 | } 72 | else if(id==1){ 73 | this.dismiss(); 74 | imageIntent.fetchFromGallery(); 75 | } 76 | } 77 | 78 | private void setDataImage() 79 | { 80 | data=new ArrayList(); 81 | data.add("TAKE PICTURE"); 82 | data.add("FETCH PHOTO FROM GALLERY"); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/ImageIntent.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo; 2 | 3 | import android.app.Activity; 4 | import android.content.ContentValues; 5 | import android.content.Context; 6 | import android.content.CursorLoader; 7 | import android.content.Intent; 8 | import android.content.SharedPreferences; 9 | import android.database.Cursor; 10 | import android.graphics.Bitmap; 11 | import android.net.Uri; 12 | import android.os.Environment; 13 | import android.provider.MediaStore; 14 | import android.text.TextUtils; 15 | import android.util.Log; 16 | 17 | import java.io.File; 18 | import java.io.FileNotFoundException; 19 | import java.io.FileOutputStream; 20 | import java.io.IOException; 21 | import java.text.SimpleDateFormat; 22 | import java.util.ArrayList; 23 | import java.util.Date; 24 | import java.util.List; 25 | 26 | import proj.me.bitframe.BeanImage; 27 | import proj.me.bitframe.FrameCallback; 28 | import proj.me.bitframe.helper.Utils; 29 | 30 | 31 | /** 32 | * Created by Deepak.Tiwari on 30-10-2015. 33 | */ 34 | public class ImageIntent { 35 | private Activity activity; 36 | private CustomDialogFrag customDialogFrag; 37 | private static final int TAKE_PHOTO = 1; 38 | private static final int FROM_GALLERY = 2; 39 | public ImageIntent(Activity activity){ 40 | this.activity = activity; 41 | } 42 | 43 | public void callIntentForImage() { 44 | customDialogFrag = new CustomDialogFrag(ImageIntent.this); 45 | customDialogFrag.show(activity.getFragmentManager(), "myImageDialog"); 46 | } 47 | 48 | void takePhoto() { 49 | Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 50 | Uri fileUri = null; 51 | try { 52 | fileUri = createImageFile(); 53 | takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); 54 | ((IntentAction)activity).picIntentInitiated(fileUri.toString()); 55 | activity.startActivityForResult(takePictureIntent, TAKE_PHOTO); 56 | } catch (IOException ex) { 57 | // Error occurred while creating the File 58 | } 59 | 60 | } 61 | 62 | void fetchFromGallery() { 63 | ((IntentAction)activity).picIntentInitiated(null); 64 | Intent intent = new Intent(Intent.ACTION_PICK, 65 | MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 66 | activity.startActivityForResult(intent, FROM_GALLERY); 67 | } 68 | 69 | Uri createImageFile() throws IOException { 70 | String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss") 71 | .format(new Date()); 72 | 73 | ContentValues values = new ContentValues(); 74 | String fileName = "IMG_" + timeStamp + ".jpg"; 75 | values.put(MediaStore.Images.Media.TITLE, fileName); 76 | return activity.getContentResolver().insert( 77 | MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); 78 | } 79 | public String getImageResultPath(Intent data, String filePath) { 80 | if((data == null || data.getData() == null) && filePath == null) return null; 81 | //Constants.logMessage("comment on image -> "+comment); 82 | String imagePath = ""; 83 | String extention = ".jpg"; 84 | if (data != null && data.getData() != null) { 85 | Uri img = data.getData(); 86 | String[] filePathClm = { MediaStore.Images.Media.DATA }; 87 | Cursor c = activity.getContentResolver().query(img, filePathClm, 88 | null, null, null); 89 | if(c != null) { 90 | c.moveToFirst(); 91 | 92 | int clmIndex = c.getColumnIndex(filePathClm[0]); 93 | //imagePath = c.getString(clmIndex); 94 | c.close(); 95 | /*if(!TextUtils.isEmpty(path)) 96 | extention = path.substring(path.lastIndexOf("."));*/ 97 | } 98 | imagePath = img.toString(); 99 | //imagePath = getPathFromURI(data.getData()); 100 | }else 101 | imagePath = filePath; 102 | return imagePath; 103 | } 104 | 105 | /** 106 | * Method to get file path from Uri 107 | * 108 | * @param contentUri uri of selected file 109 | * @return 110 | */ 111 | public String getPathFromURI(Uri contentUri) { 112 | String[] projection = {MediaStore.Images.Media.DATA}; 113 | CursorLoader cursorLoader = new CursorLoader(activity, contentUri, projection, null, null, null); 114 | Cursor cursor = cursorLoader.loadInBackground(); 115 | if(cursor == null) return null; 116 | int column_index = 117 | cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); 118 | cursor.moveToFirst(); 119 | return cursor.getString(column_index); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/IntentAction.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by root on 22/9/16. 7 | */ 8 | 9 | public interface IntentAction { 10 | void picIntentInitiated(String filePath); 11 | void addMoreImages(View view); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/ViewHolder_Dialog.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo; 2 | 3 | import android.widget.TextView; 4 | 5 | public class ViewHolder_Dialog { 6 | 7 | public TextView text; 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/adapter/FrameAdapter.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.adapter; 2 | 3 | import android.content.Context; 4 | import androidx.recyclerview.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import java.util.List; 9 | import proj.me.bitframe.BeanBitFrame; 10 | import proj.me.bitframe.FrameCallback; 11 | import proj.me.bitframe.ImageType; 12 | import proj.me.bitframe.ViewFrame; 13 | import proj.me.bitframe.helper.FrameType; 14 | import proj.me.bitframe.helper.Utils; 15 | import proj.me.bitframedemo.R; 16 | import proj.me.bitframedemo.beans.FrameBean; 17 | import proj.me.bitframedemo.binders.CardBinder; 18 | 19 | /** 20 | * Created by root on 20/9/16. 21 | */ 22 | 23 | public class FrameAdapter extends RecyclerView.Adapter{ 24 | 25 | List frameBeanList; 26 | int containerWidth; 27 | int containerHeight; 28 | public FrameAdapter(int containerWidth, int containerHeight, List frameBeanList){ 29 | this.frameBeanList = frameBeanList; 30 | this.containerWidth = containerWidth; 31 | this.containerHeight = containerHeight; 32 | } 33 | 34 | @Override 35 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 36 | LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 37 | return new ViewHolder(inflater.inflate(R.layout.card_container, parent, false), containerWidth, containerHeight); 38 | } 39 | 40 | @Override 41 | public void onBindViewHolder(ViewHolder holder, int position) { 42 | FrameBean frameBean = frameBeanList.get(position); 43 | Utils.logVerbose("IMAGE_LOADING : "+" came to load view frame at "+position); 44 | holder.cardBinder.viewFrame().clearContainerChilds(); 45 | holder.cardBinder.setTitle(frameBean.getTitle()); 46 | holder.cardBinder.setDescription(frameBean.getDescription()); 47 | holder.cardBinder.viewFrame().showBitFrame(frameBean.getBeanBitFrameList(), holder, FrameType.FRAMED); 48 | } 49 | 50 | @Override 51 | public int getItemCount() { 52 | return frameBeanList.size(); 53 | } 54 | 55 | static class ViewHolder extends RecyclerView.ViewHolder implements FrameCallback { 56 | CardBinder cardBinder = new CardBinder(); 57 | public ViewHolder(View itemView, int containerWidth, int containerHeight) { 58 | super(itemView); 59 | cardBinder.bind(itemView); 60 | cardBinder.viewFrame().setFrameDimensions(0, 0, containerWidth, containerHeight); 61 | 62 | ViewGroup.LayoutParams layoutParams = cardBinder.viewFrame().getLayoutParams(); 63 | layoutParams.width = containerWidth; 64 | layoutParams.height = containerHeight; 65 | cardBinder.viewFrame().setLayoutParams(layoutParams); 66 | cardBinder.viewFrame().invalidate(); 67 | } 68 | 69 | @Override 70 | public void imageClick(ImageType imageType, int imagePosition, String imageLink, ViewFrame actionableViewFrame) { 71 | 72 | } 73 | 74 | @Override 75 | public void frameResult(List beanBitFrameList, ViewFrame actionableViewFrame) { 76 | 77 | } 78 | 79 | @Override 80 | public void addMoreClick(ViewFrame actionableViewFrame) { 81 | 82 | } 83 | 84 | @Override 85 | public void containerAdded(int containerWidth, int containerHeight, boolean isAddInLayout, ViewFrame actionableViewFrame) { 86 | 87 | } 88 | 89 | @Override 90 | public void loadedFrameColors(int lastLoadedFrameColor, int mixedLoadedColor, int inverseMixedLoadedColor, ViewFrame actionableViewFrame) { 91 | cardBinder.setTitleColor(mixedLoadedColor); 92 | cardBinder.setDescriptionColor(mixedLoadedColor); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/beans/BaseResponse.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.beans; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 13 | 14 | @JsonInclude(JsonInclude.Include.NON_NULL) 15 | @JsonPropertyOrder({ 16 | "status", 17 | "message" 18 | }) 19 | public class BaseResponse { 20 | 21 | @JsonProperty("status") 22 | private int status; 23 | @JsonProperty("message") 24 | private String message; 25 | 26 | /** 27 | * @return The status 28 | */ 29 | @JsonProperty("status") 30 | public int getStatus() { 31 | return status; 32 | } 33 | 34 | /** 35 | * @param status The status 36 | */ 37 | @JsonProperty("status") 38 | public void setStatus(int status) { 39 | this.status = status; 40 | } 41 | 42 | /** 43 | * @return The message 44 | */ 45 | @JsonProperty("message") 46 | public String getMessage() { 47 | return message; 48 | } 49 | 50 | /** 51 | * @param message The message 52 | */ 53 | @JsonProperty("message") 54 | public void setMessage(String message) { 55 | this.message = message; 56 | } 57 | } -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/beans/BundleDetail.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.beans; 2 | import android.os.Parcel; 3 | import android.os.Parcelable; 4 | 5 | import java.util.ArrayList; 6 | import java.util.HashMap; 7 | import java.util.List; 8 | import java.util.Map; 9 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 10 | import com.fasterxml.jackson.annotation.JsonAnySetter; 11 | import com.fasterxml.jackson.annotation.JsonIgnore; 12 | import com.fasterxml.jackson.annotation.JsonInclude; 13 | import com.fasterxml.jackson.annotation.JsonProperty; 14 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 15 | /** 16 | * Created by root on 20/9/16. 17 | */ 18 | @JsonInclude(JsonInclude.Include.NON_NULL) 19 | @JsonPropertyOrder({ 20 | "_id", 21 | "bundle_id", 22 | "device_id", 23 | "images" 24 | }) 25 | public class BundleDetail implements Parcelable{ 26 | @JsonProperty("bundle_id") 27 | private int bundleId; 28 | @JsonProperty("device_id") 29 | private String deviceId; 30 | @JsonProperty("images") 31 | private List images = new ArrayList(); 32 | 33 | public BundleDetail(){} 34 | 35 | 36 | protected BundleDetail(Parcel in) { 37 | bundleId = in.readInt(); 38 | deviceId = in.readString(); 39 | images = in.createTypedArrayList(Bundle.CREATOR); 40 | } 41 | 42 | public static final Creator CREATOR = new Creator() { 43 | @Override 44 | public BundleDetail createFromParcel(Parcel in) { 45 | return new BundleDetail(in); 46 | } 47 | 48 | @Override 49 | public BundleDetail[] newArray(int size) { 50 | return new BundleDetail[size]; 51 | } 52 | }; 53 | 54 | /** 55 | * 56 | * @return 57 | * The bundleId 58 | */ 59 | @JsonProperty("bundle_id") 60 | public int getBundleId() { 61 | return bundleId; 62 | } 63 | 64 | /** 65 | * 66 | * @param bundleId 67 | * The bundle_id 68 | */ 69 | @JsonProperty("bundle_id") 70 | public void setBundleId(int bundleId) { 71 | this.bundleId = bundleId; 72 | } 73 | 74 | /** 75 | * 76 | * @return 77 | * The deviceId 78 | */ 79 | @JsonProperty("device_id") 80 | public String getDeviceId() { 81 | return deviceId; 82 | } 83 | 84 | /** 85 | * 86 | * @param deviceId 87 | * The device_id 88 | */ 89 | @JsonProperty("device_id") 90 | public void setDeviceId(String deviceId) { 91 | this.deviceId = deviceId; 92 | } 93 | 94 | /** 95 | * 96 | * @return 97 | * The images 98 | */ 99 | @JsonProperty("images") 100 | public List getImages() { 101 | return images; 102 | } 103 | 104 | /** 105 | * 106 | * @param images 107 | * The images 108 | */ 109 | @JsonProperty("images") 110 | public void setImages(List images) { 111 | this.images = images; 112 | } 113 | 114 | @Override 115 | public int describeContents() { 116 | return 0; 117 | } 118 | 119 | @Override 120 | public void writeToParcel(Parcel dest, int flags) { 121 | dest.writeInt(bundleId); 122 | dest.writeString(deviceId); 123 | dest.writeTypedList(images); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/beans/FrameBean.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.beans; 2 | 3 | import java.util.List; 4 | 5 | import proj.me.bitframe.BeanBitFrame; 6 | import proj.me.bitframe.BeanImage; 7 | 8 | /** 9 | * Created by root on 20/9/16. 10 | */ 11 | 12 | public class FrameBean { 13 | private String title; 14 | private String description; 15 | private List beanBitFrameList; 16 | 17 | 18 | public String getTitle() { 19 | return title; 20 | } 21 | 22 | public void setTitle(String title) { 23 | this.title = title; 24 | } 25 | 26 | public String getDescription() { 27 | return description; 28 | } 29 | 30 | public void setDescription(String description) { 31 | this.description = description; 32 | } 33 | 34 | public List getBeanBitFrameList() { 35 | return beanBitFrameList; 36 | } 37 | 38 | public void setBeanBitFrameList(List beanBitFrameList) { 39 | this.beanBitFrameList = beanBitFrameList; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/beans/FrameResponse.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.beans; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | import com.fasterxml.jackson.annotation.JsonAnyGetter; 12 | import com.fasterxml.jackson.annotation.JsonAnySetter; 13 | import com.fasterxml.jackson.annotation.JsonIgnore; 14 | import com.fasterxml.jackson.annotation.JsonInclude; 15 | import com.fasterxml.jackson.annotation.JsonProperty; 16 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 17 | 18 | @JsonInclude(JsonInclude.Include.NON_NULL) 19 | @JsonPropertyOrder({ 20 | "status", 21 | "message", 22 | "bundle" 23 | }) 24 | public class FrameResponse implements Parcelable{ 25 | 26 | @JsonProperty("status") 27 | private int status; 28 | @JsonProperty("message") 29 | private String message; 30 | @JsonProperty("bundle") 31 | private List bundle = new ArrayList(); 32 | 33 | public FrameResponse(){} 34 | 35 | protected FrameResponse(Parcel in) { 36 | status = in.readInt(); 37 | message = in.readString(); 38 | bundle = in.createTypedArrayList(BundleDetail.CREATOR); 39 | } 40 | 41 | public static final Creator CREATOR = new Creator() { 42 | @Override 43 | public FrameResponse createFromParcel(Parcel in) { 44 | return new FrameResponse(in); 45 | } 46 | 47 | @Override 48 | public FrameResponse[] newArray(int size) { 49 | return new FrameResponse[size]; 50 | } 51 | }; 52 | 53 | /** 54 | * @return The status 55 | */ 56 | @JsonProperty("status") 57 | public int getStatus() { 58 | return status; 59 | } 60 | 61 | /** 62 | * @param status The status 63 | */ 64 | @JsonProperty("status") 65 | public void setStatus(int status) { 66 | this.status = status; 67 | } 68 | 69 | /** 70 | * @return The message 71 | */ 72 | @JsonProperty("message") 73 | public String getMessage() { 74 | return message; 75 | } 76 | 77 | /** 78 | * @param message The message 79 | */ 80 | @JsonProperty("message") 81 | public void setMessage(String message) { 82 | this.message = message; 83 | } 84 | 85 | /** 86 | * @return The bundle 87 | */ 88 | @JsonProperty("bundle") 89 | public List getBundle() { 90 | return bundle; 91 | } 92 | 93 | /** 94 | * @param bundle The bundle 95 | */ 96 | @JsonProperty("bundle") 97 | public void setBundle(List bundle) { 98 | this.bundle = bundle; 99 | } 100 | 101 | @Override 102 | public int describeContents() { 103 | return 0; 104 | } 105 | 106 | @Override 107 | public void writeToParcel(Parcel dest, int flags) { 108 | dest.writeInt(status); 109 | dest.writeString(message); 110 | dest.writeTypedList(bundle); 111 | } 112 | } -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/beans/NextBundle.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.beans; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | import com.fasterxml.jackson.annotation.JsonInclude; 11 | import com.fasterxml.jackson.annotation.JsonProperty; 12 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 13 | 14 | @JsonInclude(JsonInclude.Include.NON_NULL) 15 | @JsonPropertyOrder({ 16 | "status", 17 | "message", 18 | "bundle_id" 19 | }) 20 | public class NextBundle implements Parcelable{ 21 | 22 | @JsonProperty("status") 23 | private int status; 24 | @JsonProperty("message") 25 | private String message; 26 | @JsonProperty("bundle_id") 27 | private int bundleId; 28 | 29 | public NextBundle(){} 30 | protected NextBundle(Parcel in) { 31 | status = in.readInt(); 32 | message = in.readString(); 33 | bundleId = in.readInt(); 34 | } 35 | 36 | public static final Creator CREATOR = new Creator() { 37 | @Override 38 | public NextBundle createFromParcel(Parcel in) { 39 | return new NextBundle(in); 40 | } 41 | 42 | @Override 43 | public NextBundle[] newArray(int size) { 44 | return new NextBundle[size]; 45 | } 46 | }; 47 | 48 | /** 49 | * @return The status 50 | */ 51 | @JsonProperty("status") 52 | public int getStatus() { 53 | return status; 54 | } 55 | 56 | /** 57 | * @param status The status 58 | */ 59 | @JsonProperty("status") 60 | public void setStatus(int status) { 61 | this.status = status; 62 | } 63 | 64 | /** 65 | * @return The message 66 | */ 67 | @JsonProperty("message") 68 | public String getMessage() { 69 | return message; 70 | } 71 | 72 | /** 73 | * @param message The message 74 | */ 75 | @JsonProperty("message") 76 | public void setMessage(String message) { 77 | this.message = message; 78 | } 79 | 80 | /** 81 | * @return The bundleId 82 | */ 83 | @JsonProperty("bundle_id") 84 | public int getBundleId() { 85 | return bundleId; 86 | } 87 | 88 | /** 89 | * @param bundleId The bundle_id 90 | */ 91 | @JsonProperty("bundle_id") 92 | public void setBundleId(int bundleId) { 93 | this.bundleId = bundleId; 94 | } 95 | 96 | @Override 97 | public int describeContents() { 98 | return 0; 99 | } 100 | 101 | @Override 102 | public void writeToParcel(Parcel dest, int flags) { 103 | dest.writeInt(status); 104 | dest.writeString(message); 105 | dest.writeInt(bundleId); 106 | } 107 | } -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/beans/UploadRequest.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.beans; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 7 | 8 | /** 9 | * Created by root on 18/9/16. 10 | */ 11 | 12 | @JsonInclude(JsonInclude.Include.NON_NULL) 13 | @JsonPropertyOrder({ 14 | "device_id", 15 | "request_id", 16 | "bundle_id", 17 | "bundle" 18 | }) 19 | public class UploadRequest { 20 | @JsonProperty("device_id") 21 | private String deviceId; 22 | @JsonProperty("request_id") 23 | private int requestId; 24 | @JsonProperty("bundle_id") 25 | private int bundleId; 26 | @JsonProperty("bundle") 27 | private Bundle bundle; 28 | 29 | /** 30 | * 31 | * @return 32 | * The deviceId 33 | */ 34 | @JsonProperty("device_id") 35 | public String getDeviceId() { 36 | return deviceId; 37 | } 38 | 39 | /** 40 | * 41 | * @param deviceId 42 | * The device_id 43 | */ 44 | @JsonProperty("device_id") 45 | public void setDeviceId(String deviceId) { 46 | this.deviceId = deviceId; 47 | } 48 | 49 | /** 50 | * 51 | * @return 52 | * The requestId 53 | */ 54 | @JsonProperty("request_id") 55 | public int getRequestId() { 56 | return requestId; 57 | } 58 | 59 | /** 60 | * 61 | * @param requestId 62 | * The request_id 63 | */ 64 | @JsonProperty("request_id") 65 | public void setRequestId(int requestId) { 66 | this.requestId = requestId; 67 | } 68 | 69 | /** 70 | * 71 | * @return 72 | * The bundleId 73 | */ 74 | @JsonProperty("bundle_id") 75 | public int getBundleId() { 76 | return bundleId; 77 | } 78 | 79 | /** 80 | * 81 | * @param bundleId 82 | * The bundle_id 83 | */ 84 | @JsonProperty("bundle_id") 85 | public void setBundleId(int bundleId) { 86 | this.bundleId = bundleId; 87 | } 88 | 89 | /** 90 | * 91 | * @return 92 | * The bundle 93 | */ 94 | @JsonProperty("bundle") 95 | public Bundle getBundle() { 96 | return bundle; 97 | } 98 | 99 | /** 100 | * 101 | * @param bundle 102 | * The bundle 103 | */ 104 | @JsonProperty("bundle") 105 | public void setBundle(Bundle bundle) { 106 | this.bundle = bundle; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/binders/CardBinder.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.binders; 2 | 3 | 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import proj.me.bitframe.ViewFrame; 8 | import proj.me.bitframedemo.R; 9 | 10 | /** 11 | * Created by root on 20/9/16. 12 | */ 13 | 14 | public class CardBinder { 15 | 16 | private View root; 17 | 18 | public View bind(View root) { 19 | this.root = root; 20 | return root; 21 | } 22 | 23 | public ViewFrame viewFrame() { 24 | return root.findViewById(R.id.view_frame); 25 | } 26 | 27 | public void setTitle(String title) { 28 | TextView textView = root.findViewById(R.id.title_text); 29 | textView.setText(title); 30 | } 31 | 32 | public void setDescription(String description) { 33 | TextView textView = root.findViewById(R.id.description_text); 34 | textView.setText(description); 35 | } 36 | 37 | public void setTitleColor(int titleColor) { 38 | TextView textView = root.findViewById(R.id.title_text); 39 | textView.setTextColor(titleColor); 40 | } 41 | 42 | public void setDescriptionColor(int descriptionColor) { 43 | TextView textView = root.findViewById(R.id.description_text); 44 | textView.setTextColor(descriptionColor); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/binders/FrameBinder.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.binders; 2 | 3 | 4 | import android.view.View; 5 | import android.widget.TextView; 6 | 7 | import androidx.recyclerview.widget.RecyclerView; 8 | 9 | import com.google.android.material.floatingactionbutton.FloatingActionButton; 10 | 11 | import proj.me.bitframedemo.R; 12 | 13 | /** 14 | * Created by root on 20/9/16. 15 | */ 16 | 17 | public class FrameBinder { 18 | 19 | private View root; 20 | public View bind(View root, final View.OnClickListener clickHandler) { 21 | this.root = root; 22 | 23 | root.findViewById(R.id.error_text).setOnClickListener(new View.OnClickListener() { 24 | @Override 25 | public void onClick(View view) { 26 | clickHandler.onClick(view); 27 | } 28 | }); 29 | 30 | root.findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() { 31 | @Override 32 | public void onClick(View view) { 33 | clickHandler.onClick(view); 34 | } 35 | }); 36 | 37 | return root; 38 | } 39 | 40 | public RecyclerView recyclerFrame() { 41 | return root.findViewById(R.id.recycler_frame); 42 | } 43 | 44 | public FloatingActionButton fab() { 45 | return root.findViewById(R.id.fab); 46 | } 47 | 48 | public void setErrorText(String errorText) { 49 | TextView textView = root.findViewById(R.id.error_text); 50 | textView.setText(errorText); 51 | } 52 | 53 | public void setHasData(boolean hasData) { 54 | root.findViewById(R.id.recycler_frame).setVisibility(hasData ? View.VISIBLE : View.GONE); 55 | root.findViewById(R.id.error_text).setVisibility(hasData ? View.GONE : View.VISIBLE); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/broadcasts/ConnectivityReceiver.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.broadcasts; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | import proj.me.bitframe.helper.Utils; 8 | import proj.me.bitframedemo.helper.Constants; 9 | 10 | /** 11 | * Created by root on 17/9/16. 12 | */ 13 | 14 | public class ConnectivityReceiver extends BroadcastReceiver{ 15 | @Override 16 | public void onReceive(Context context, Intent intent) { 17 | boolean isConnected = Utils.hasNetwork(context.getApplicationContext()); 18 | 19 | if(isConnected){ 20 | Utils.logVerbose("connected"); 21 | Intent notifyActivity = new Intent(Constants.NETWORK_FILTER); 22 | notifyActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 23 | notifyActivity.putExtra("cause", Constants.NETWORK_ENABLED); 24 | context.startActivity(notifyActivity); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/broadcasts/UploadReceiver.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.broadcasts; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | import proj.me.bitframe.helper.Utils; 8 | import proj.me.bitframedemo.helper.Constants; 9 | 10 | /** 11 | * Created by root on 21/9/16. 12 | */ 13 | 14 | public class UploadReceiver extends BroadcastReceiver{ 15 | 16 | @Override 17 | public void onReceive(Context context, Intent intent) { 18 | String action = intent.getAction(); 19 | Utils.logVerbose("came in broadcast"); 20 | switch(action){ 21 | case Constants.UPLOAD_DONE: 22 | Utils.logVerbose("came in broadcast upload done"); 23 | Intent notifyActivity = new Intent(Constants.UPLOAD_FILTER); 24 | notifyActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 25 | notifyActivity.putExtra("cause", Constants.UPLOAD_DONE); 26 | context.startActivity(notifyActivity); 27 | break; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/helper/Constants.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.helper; 2 | 3 | /** 4 | * Created by root on 17/9/16. 5 | */ 6 | 7 | public class Constants { 8 | public static final int SERVICE_CALL_1 = 1; 9 | public static final int SERVICE_CALL_2 = 2; 10 | public static final int SERVICE_CALL_3 = 3; 11 | public static final int SERVICE_CALL_4 = 4; 12 | 13 | public static final int RESET_CALL_1 = 1; 14 | public static final int RESET_CALL_2 = 2; 15 | public static final int RESET_CALL_3 = 3; 16 | public static final int RESET_CALL_4 = 4; 17 | 18 | public static final String WRONG = "Could not process request!"; 19 | 20 | public static final String NETWORK_FILTER = "ACTIVITY.NETWORK_ENABLED"; 21 | public static final String NETWORK_ENABLED = "NETWORK_ENABLED"; 22 | public static final String UPLOAD_FILTER = "ACTIVITY.UPLOAD_DONE"; 23 | public static final String UPLOAD_DONE = "UPLOAD_DONE"; 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/network/DownloadImpl.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.network; 2 | 3 | import proj.me.bitframedemo.beans.FrameResponse; 4 | import retrofit2.Call; 5 | import retrofit2.http.GET; 6 | import retrofit2.http.Query; 7 | 8 | /** 9 | * Created by root on 20/9/16. 10 | */ 11 | 12 | public interface DownloadImpl { 13 | @GET("getDeviceBundle") 14 | Call getDeviceBundle(@Query("device_id") String deviceId); 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/network/RetrofitClient.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.network; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.DeserializationFeature; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | 7 | import java.io.IOException; 8 | import java.lang.annotation.Annotation; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | import java.util.concurrent.TimeUnit; 12 | 13 | import okhttp3.OkHttpClient; 14 | import okhttp3.ResponseBody; 15 | import proj.me.bitframedemo.beans.BaseResponse; 16 | import retrofit2.Converter; 17 | import retrofit2.Response; 18 | import retrofit2.Retrofit; 19 | import retrofit2.converter.jackson.JacksonConverterFactory; 20 | 21 | /** 22 | * Created by root on 17/9/16. 23 | */ 24 | 25 | public class RetrofitClient { 26 | static RetrofitClient retrofitClient; 27 | 28 | Retrofit retrofit; 29 | ObjectMapper objectMapper; 30 | Map implObject; 31 | 32 | private RetrofitClient(){ 33 | objectMapper = new ObjectMapper(); 34 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 35 | 36 | 37 | OkHttpClient okHttpClient = new OkHttpClient.Builder() 38 | .connectTimeout(3, TimeUnit.MINUTES) 39 | .readTimeout(3, TimeUnit.MINUTES) 40 | .build(); 41 | 42 | 43 | retrofit = new Retrofit.Builder() 44 | .baseUrl("http://frame-node12345js.rhcloud.com/") 45 | .addConverterFactory(JacksonConverterFactory.create(objectMapper)) 46 | .client(okHttpClient) 47 | .build(); 48 | } 49 | 50 | public static RetrofitClient createClient(){ 51 | if(retrofitClient != null) return retrofitClient; 52 | return retrofitClient = new RetrofitClient<>(); 53 | } 54 | 55 | public T getRetrofitImpl(Class classObj, int classId){ 56 | if(implObject == null) implObject = new HashMap<>(); 57 | else if(implObject.containsKey(classId)) return implObject.get(classId); 58 | T obj = retrofit.create(classObj); 59 | implObject.put(classId, obj); 60 | return obj; 61 | } 62 | 63 | public String getJsonObject(V object){ 64 | String jsonObj = null; 65 | try { 66 | jsonObj = objectMapper.writeValueAsString(object); 67 | } catch (JsonProcessingException e) { 68 | e.printStackTrace(); 69 | } 70 | return jsonObj; 71 | } 72 | 73 | public V getErrorRespose(Class classObj, Response response) throws IOException { 74 | Converter errorConverter = retrofit.responseBodyConverter(classObj, new Annotation[0]); 75 | return errorConverter.convert(response.errorBody()); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/network/RetrofitImpl.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.network; 2 | 3 | import proj.me.bitframedemo.beans.NextBundle; 4 | import retrofit2.Call; 5 | import retrofit2.http.GET; 6 | import retrofit2.http.Query; 7 | 8 | /** 9 | * Created by root on 17/9/16. 10 | */ 11 | 12 | public interface RetrofitImpl { 13 | @GET("getNextBundle") 14 | Call getNextBundle(@Query("device_id") String deviceId, @Query("request_id") int requestId); 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/proj/me/bitframedemo/network/UploadImpl.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframedemo.network; 2 | 3 | import okhttp3.RequestBody; 4 | import proj.me.bitframedemo.beans.BaseResponse; 5 | import proj.me.bitframedemo.beans.UploadRequest; 6 | import retrofit2.Call; 7 | import retrofit2.http.Body; 8 | import retrofit2.http.Multipart; 9 | import retrofit2.http.POST; 10 | import retrofit2.http.Part; 11 | 12 | /** 13 | * Created by root on 18/9/16. 14 | */ 15 | 16 | public interface UploadImpl { 17 | 18 | @Multipart 19 | @POST("uploadBundle") 20 | Call uploadImage(@Part("file\"; fileName=\"myFile.png\" ")RequestBody requestBodyFile, @Part("image") RequestBody requestBodyJson); 21 | 22 | @POST("postBundle") 23 | Call postBundle(@Body UploadRequest uploadRequest); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/round_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_frame.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 25 | 40 | 53 | -------------------------------------------------------------------------------- /app/src/main/res/layout/card_container.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 18 | 19 | 24 | 25 | 32 | 33 | 41 | 42 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/res/layout/custom_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/custom_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/frame_recycler.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 17 | 18 | 26 | 27 | 28 | 29 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/menu/upload_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BitFrames 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /bitframe/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /bitframe/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 30 5 | buildToolsVersion "25.0.3" 6 | 7 | defaultConfig { 8 | minSdkVersion 19 9 | targetSdkVersion 30 10 | versionCode 6 11 | versionName "1.6" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies{ 22 | testImplementation 'junit:junit:4.12' 23 | testImplementation 'org.mockito:mockito-core:1.10.19' 24 | testImplementation 'org.hamcrest:hamcrest-all:1.3' 25 | 26 | api 'com.squareup.picasso:picasso:2.5.2' 27 | api 'androidx.palette:palette:1.0.0' 28 | } 29 | -------------------------------------------------------------------------------- /bitframe/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /media/deepak_t/mydrive/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /bitframe/src/androidTest/java/proj/me/bitframe/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /bitframe/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/BeanBitFrame.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * Created by root on 17/4/16. 8 | */ 9 | public class BeanBitFrame extends BeanImage{ 10 | float width, height; 11 | int vibrantColor, mutedColor; 12 | 13 | boolean isLoaded; 14 | 15 | boolean hasGreaterVibrantPopulation; 16 | public BeanBitFrame(){ 17 | super(); 18 | } 19 | 20 | protected BeanBitFrame(Parcel in) { 21 | super(in); 22 | width = in.readFloat(); 23 | height = in.readFloat(); 24 | vibrantColor = in.readInt(); 25 | mutedColor = in.readInt(); 26 | isLoaded = in.readByte() != 0; 27 | hasGreaterVibrantPopulation = in.readByte() != 0; 28 | } 29 | 30 | @Override 31 | public void writeToParcel(Parcel dest, int flags) { 32 | super.writeToParcel(dest, flags); 33 | dest.writeFloat(width); 34 | dest.writeFloat(height); 35 | dest.writeInt(vibrantColor); 36 | dest.writeInt(mutedColor); 37 | dest.writeByte((byte) (isLoaded ? 1 : 0)); 38 | dest.writeByte((byte) (hasGreaterVibrantPopulation ? 1 : 0)); 39 | } 40 | 41 | @Override 42 | public int describeContents() { 43 | return 0; 44 | } 45 | 46 | public static final Creator CREATOR = new Creator() { 47 | @Override 48 | public BeanBitFrame createFromParcel(Parcel in) { 49 | return new BeanBitFrame(in); 50 | } 51 | 52 | @Override 53 | public BeanBitFrame[] newArray(int size) { 54 | return new BeanBitFrame[size]; 55 | } 56 | }; 57 | public boolean isHasGreaterVibrantPopulation() { 58 | return hasGreaterVibrantPopulation; 59 | } 60 | 61 | public void setHasGreaterVibrantPopulation(boolean hasGreaterVibrantPopulation) { 62 | this.hasGreaterVibrantPopulation = hasGreaterVibrantPopulation; 63 | } 64 | 65 | public boolean isLoaded() { 66 | return isLoaded; 67 | } 68 | 69 | public void setLoaded(boolean loaded) { 70 | isLoaded = loaded; 71 | } 72 | 73 | public float getWidth() { 74 | return width; 75 | } 76 | 77 | public void setWidth(float width) { 78 | this.width = width; 79 | } 80 | 81 | public float getHeight() { 82 | return height; 83 | } 84 | 85 | public void setHeight(float height) { 86 | this.height = height; 87 | } 88 | 89 | public int getVibrantColor() { 90 | return vibrantColor; 91 | } 92 | 93 | public void setVibrantColor(int vibrantColor) { 94 | this.vibrantColor = vibrantColor; 95 | } 96 | 97 | public int getMutedColor() { 98 | return mutedColor; 99 | } 100 | 101 | public void setMutedColor(int mutedColor) { 102 | this.mutedColor = mutedColor; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/BeanHandler.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import proj.me.bitframe.BeanImage; 6 | 7 | /** 8 | * Created by root on 16/9/16. 9 | */ 10 | 11 | class BeanHandler { 12 | private Bitmap bitmap; 13 | private BeanImage beanImage; 14 | 15 | public Bitmap getBitmap() { 16 | return bitmap; 17 | } 18 | 19 | public void setBitmap(Bitmap bitmap) { 20 | this.bitmap = bitmap; 21 | } 22 | 23 | public BeanImage getBeanImage() { 24 | return beanImage; 25 | } 26 | 27 | public void setBeanImage(BeanImage beanImage) { 28 | this.beanImage = beanImage; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/BeanImage.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import java.util.Comparator; 7 | 8 | /** 9 | * Created by root on 17/4/16. 10 | */ 11 | public class BeanImage implements Comparable, Parcelable { 12 | String imageLink; 13 | String imageComment; 14 | int primaryCount, secondaryCount; 15 | 16 | public BeanImage(){} 17 | 18 | protected BeanImage(Parcel in) { 19 | imageLink = in.readString(); 20 | imageComment = in.readString(); 21 | primaryCount = in.readInt(); 22 | secondaryCount = in.readInt(); 23 | } 24 | 25 | public static final Creator CREATOR = new Creator() { 26 | @Override 27 | public BeanImage createFromParcel(Parcel in) { 28 | return new BeanImage(in); 29 | } 30 | 31 | @Override 32 | public BeanImage[] newArray(int size) { 33 | return new BeanImage[size]; 34 | } 35 | }; 36 | 37 | 38 | public String getImageLink() { 39 | return imageLink; 40 | } 41 | 42 | public void setImageLink(String imageLink) { 43 | this.imageLink = imageLink; 44 | } 45 | 46 | public String getImageComment() { 47 | return imageComment; 48 | } 49 | 50 | public void setImageComment(String imageComment) { 51 | this.imageComment = imageComment; 52 | } 53 | 54 | public int getPrimaryCount() { 55 | return primaryCount; 56 | } 57 | 58 | public void setPrimaryCount(int primaryCount) { 59 | this.primaryCount = primaryCount; 60 | } 61 | 62 | public int getSecondaryCount() { 63 | return secondaryCount; 64 | } 65 | 66 | public void setSecondaryCount(int secondaryCount) { 67 | this.secondaryCount = secondaryCount; 68 | } 69 | 70 | @Override 71 | public int compareTo(BeanImage another) { 72 | /*//if in right order then <= 0 73 | //else need to interchange so > 0 74 | if(primaryCount == another.getPrimaryCount() && secondaryCount == another.getSecondaryCount()) return 0; 75 | else if(primaryCount < another.getPrimaryCount()) return 1;//need to interchange a/c to our requirement 76 | else if(primaryCount > another.getPrimaryCount()) return -1;//are in right order a/c to our requirement 77 | else if(secondaryCount < another.getSecondaryCount()) return 1; 78 | else if(secondaryCount > another.getSecondaryCount()) return -1; 79 | return 1;*/ 80 | 81 | int first = Math.max(primaryCount + ImageShading.SORT_DIFFERENCE_THRESHOLD, secondaryCount); 82 | int second = Math.max(another.getPrimaryCount() + ImageShading.SORT_DIFFERENCE_THRESHOLD, another.getSecondaryCount()); 83 | 84 | return second - first; 85 | } 86 | 87 | 88 | @Override 89 | public int describeContents() { 90 | return 0; 91 | } 92 | 93 | @Override 94 | public void writeToParcel(Parcel dest, int flags) { 95 | dest.writeString(imageLink); 96 | dest.writeString(imageComment); 97 | dest.writeInt(primaryCount); 98 | dest.writeInt(secondaryCount); 99 | } 100 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/BinadingBitFrame.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.content.res.ColorStateList; 4 | import android.os.Build; 5 | import android.view.View; 6 | import android.widget.ProgressBar; 7 | 8 | /** 9 | * Created by root on 13/3/16. 10 | */ 11 | public class BinadingBitFrame { 12 | 13 | private View root; 14 | 15 | View bind(View root) { 16 | this.root = root; 17 | return root; 18 | } 19 | 20 | public void setProgressBarVisibility(boolean progressBarVisibility) { 21 | ProgressBar progressBar = root.findViewById(R.id.progress_loader); 22 | progressBar.setVisibility(progressBarVisibility ? View.VISIBLE : View.GONE); 23 | } 24 | 25 | public void setProgressBarColor(int progressBarColor) { 26 | ProgressBar progressBar = root.findViewById(R.id.progress_loader); 27 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 28 | progressBar.setBackgroundTintList(ColorStateList.valueOf(progressBarColor)); 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/FrameCallback.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by root on 18/4/16. 7 | */ 8 | public interface FrameCallback { 9 | //1 2 10 | //3 4 11 | /** 12 | * @param imageType single to multiplevalue will be null if image has not been loaded. 13 | * @param imagePosition defined in horizontal way. 14 | * @param imageLink the link of the clicked image 15 | * */ 16 | void imageClick(ImageType imageType, int imagePosition, String imageLink, ViewFrame actionableViewFrame); 17 | /** 18 | * the result after all image links loaded 19 | * */ 20 | void frameResult(List beanBitFrameList, ViewFrame actionableViewFrame); 21 | /** 22 | * when add overflow clicked, if it's been added the the container 23 | * */ 24 | void addMoreClick(ViewFrame actionableViewFrame); 25 | 26 | void containerAdded(int containerWidth, int containerHeight, boolean isAddInLayout, ViewFrame actionableViewFrame); 27 | 28 | void loadedFrameColors(int lastLoadedFrameColor, int mixedLoadedColor, int inverseMixedLoadedColor, ViewFrame actionableViewFrame); 29 | } 30 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/FrameHandler.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.graphics.Bitmap; 4 | import android.os.Handler; 5 | import android.os.Message; 6 | import androidx.palette.graphics.Palette; 7 | 8 | import proj.me.bitframe.exceptions.FrameException; 9 | 10 | class FrameHandler extends Handler { 11 | ImageResult imageResult; 12 | 13 | FrameHandler(ImageResult imageResult) { 14 | this.imageResult = imageResult; 15 | } 16 | 17 | @Override 18 | public void handleMessage(Message msg) { 19 | 20 | switch (msg.what) { 21 | case 1: 22 | final BeanHandler beanHandler = (BeanHandler) msg.obj; 23 | final Bitmap bitmap = beanHandler.getBitmap(); 24 | if (imageResult.getCounter() >= imageResult.getFrameModel().getMaxFrameCount()) { 25 | imageResult.updateCounter(); 26 | final BeanBitFrame beanBitFrame = new BeanBitFrame(); 27 | beanBitFrame.setWidth(bitmap.getWidth()); 28 | beanBitFrame.setHeight(bitmap.getHeight()); 29 | beanBitFrame.setLoaded(true); 30 | 31 | Palette.from(bitmap).generate(new PaletteListener(imageResult, beanBitFrame, beanHandler.getBeanImage(), false)); 32 | } else { 33 | boolean doneLoading = imageResult.getCounter() == (imageResult.getFrameModel().getMaxFrameCount() 34 | >= imageResult.getTotalImages() ? imageResult.getTotalImages() 35 | : imageResult.getFrameModel().getMaxFrameCount()) - 1; 36 | imageResult.setDoneLoading(doneLoading); 37 | try { 38 | imageResult.onImageLoaded(true, bitmap, beanHandler.getBeanImage()); 39 | } catch (FrameException e) { 40 | e.printStackTrace(); 41 | } 42 | imageResult.updateCounter(); 43 | } 44 | break; 45 | case 3: 46 | Bitmap bit = (Bitmap) msg.obj; 47 | if (!bit.isRecycled()) bit.recycle(); 48 | bit = null; 49 | break; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/FrameModel.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.widget.ImageView; 4 | 5 | import proj.me.bitframe.helper.ColorCombination; 6 | 7 | /** 8 | * Created by root on 18/4/16. 9 | */ 10 | public class FrameModel { 11 | int commentTransparencyPercent; 12 | int sortDifferenceThreshold; 13 | float minFrameWidth; 14 | float minFrameHeight; 15 | float maxContainerWidth; 16 | float maxContainerHeight; 17 | int maxFrameCount; 18 | int maxExtraCount; 19 | float minAddRatio; 20 | boolean isAddInLayout; 21 | boolean hasLoader; 22 | boolean hasLoadingDrawable; 23 | boolean hasScroll; 24 | boolean shouldShowComment; 25 | boolean hasFixedDimensions; 26 | boolean shouldSortImages; 27 | ColorCombination colorCombination; 28 | ImageView.ScaleType scaleType; 29 | int errorDrawable; 30 | int loadingDrawable; 31 | boolean shouldRecycleBitmaps; 32 | boolean shouldStoreImages; 33 | 34 | public boolean isShouldStoreImages() { 35 | return shouldStoreImages; 36 | } 37 | 38 | public void setShouldStoreImages(boolean shouldStoreImages) { 39 | this.shouldStoreImages = shouldStoreImages; 40 | } 41 | 42 | public boolean isShouldRecycleBitmaps() { 43 | return shouldRecycleBitmaps; 44 | } 45 | 46 | public void setShouldRecycleBitmaps(boolean shouldRecycleBitmaps) { 47 | this.shouldRecycleBitmaps = shouldRecycleBitmaps; 48 | } 49 | 50 | public boolean isHasScroll() { 51 | return hasScroll; 52 | } 53 | 54 | public void setHasScroll(boolean hasScroll) { 55 | this.hasScroll = hasScroll; 56 | } 57 | 58 | public boolean isShouldSortImages() { 59 | return shouldSortImages; 60 | } 61 | 62 | public void setShouldSortImages(boolean shouldSortImages) { 63 | this.shouldSortImages = shouldSortImages; 64 | } 65 | 66 | public int getCommentTransparencyPercent() { 67 | return commentTransparencyPercent; 68 | } 69 | 70 | public void setCommentTransparencyPercent(int commentTransparencyPercent) { 71 | this.commentTransparencyPercent = commentTransparencyPercent; 72 | } 73 | 74 | public int getSortDifferenceThreshold() { 75 | return sortDifferenceThreshold; 76 | } 77 | 78 | public void setSortDifferenceThreshold(int sortDifferenceThreshold) { 79 | this.sortDifferenceThreshold = sortDifferenceThreshold; 80 | } 81 | 82 | public boolean isHasFixedDimensions() { 83 | return hasFixedDimensions; 84 | } 85 | 86 | public void setHasFixedDimensions(boolean hasFixedDimensions) { 87 | this.hasFixedDimensions = hasFixedDimensions; 88 | } 89 | 90 | public float getMinFrameWidth() { 91 | return minFrameWidth; 92 | } 93 | 94 | public void setMinFrameWidth(float minFrameWidth) { 95 | this.minFrameWidth = minFrameWidth; 96 | } 97 | 98 | public float getMinFrameHeight() { 99 | return minFrameHeight; 100 | } 101 | 102 | public void setMinFrameHeight(float minFrameHeight) { 103 | this.minFrameHeight = minFrameHeight; 104 | } 105 | 106 | public float getMaxContainerWidth() { 107 | return maxContainerWidth; 108 | } 109 | 110 | public void setMaxContainerWidth(float maxContainerWidth) { 111 | this.maxContainerWidth = maxContainerWidth; 112 | } 113 | 114 | public float getMaxContainerHeight() { 115 | return maxContainerHeight; 116 | } 117 | 118 | public void setMaxContainerHeight(float maxContainerHeight) { 119 | this.maxContainerHeight = maxContainerHeight; 120 | } 121 | 122 | public int getMaxFrameCount() { 123 | return maxFrameCount; 124 | } 125 | 126 | public void setMaxFrameCount(int maxFrameCount) { 127 | this.maxFrameCount = maxFrameCount; 128 | } 129 | 130 | public int getMaxExtraCount() { 131 | return maxExtraCount; 132 | } 133 | 134 | public void setMaxExtraCount(int maxExtraCount) { 135 | this.maxExtraCount = maxExtraCount; 136 | } 137 | 138 | public float getMinAddRatio() { 139 | return minAddRatio; 140 | } 141 | 142 | public void setMinAddRatio(float minAddRatio) { 143 | this.minAddRatio = minAddRatio; 144 | } 145 | 146 | public boolean isAddInLayout() { 147 | return isAddInLayout; 148 | } 149 | 150 | public void setAddInLayout(boolean addInLayout) { 151 | isAddInLayout = addInLayout; 152 | } 153 | 154 | public boolean isShouldShowComment() { 155 | return shouldShowComment; 156 | } 157 | 158 | public void setShouldShowComment(boolean shouldShowComment) { 159 | this.shouldShowComment = shouldShowComment; 160 | } 161 | 162 | public ColorCombination getColorCombination() { 163 | return colorCombination; 164 | } 165 | 166 | public void setColorCombination(ColorCombination colorCombination) { 167 | this.colorCombination = colorCombination; 168 | } 169 | 170 | public ImageView.ScaleType getScaleType() { 171 | return scaleType; 172 | } 173 | 174 | public void setScaleType(ImageView.ScaleType scaleType) { 175 | this.scaleType = scaleType; 176 | } 177 | 178 | public int getErrorDrawable() { 179 | return errorDrawable; 180 | } 181 | 182 | public void setErrorDrawable(int errorDrawable) { 183 | this.errorDrawable = errorDrawable; 184 | } 185 | 186 | public boolean isHasLoader() { 187 | return hasLoader; 188 | } 189 | 190 | public void setHasLoader(boolean hasLoader) { 191 | this.hasLoader = hasLoader; 192 | } 193 | 194 | public boolean isHasLoadingDrawable() { 195 | return hasLoadingDrawable; 196 | } 197 | 198 | public void setHasLoadingDrawable(boolean hasLoadingDrawable) { 199 | this.hasLoadingDrawable = hasLoadingDrawable; 200 | } 201 | 202 | public int getLoadingDrawable() { 203 | return loadingDrawable; 204 | } 205 | 206 | public void setLoadingDrawable(int loadingDrawable) { 207 | this.loadingDrawable = loadingDrawable; 208 | } 209 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/ImageCallback.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.content.Intent; 4 | import android.graphics.Bitmap; 5 | import android.view.View; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Deepak.Tiwari on 30-10-2015. 11 | */ 12 | interface ImageCallback { 13 | void addImageView(View view, int viewWidth, int viewHeight, boolean hasAddInLayout); 14 | //1 2 15 | //3 4 16 | /** 17 | * @param imageType single to multiplevalue will be null if image has not been loaded. 18 | * @param imagePosition defined in horizontal way. 19 | * @param imageLink the link of the clicked image 20 | * */ 21 | void imageClicked(ImageType imageType, int imagePosition, String imageLink); 22 | 23 | void setColorsToAddMoreView(int resultColor, int mixedColor, int invertedColor); 24 | 25 | void frameResult(BeanBitFrame ... beanBitFrames); 26 | 27 | void addMore(); 28 | } 29 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/ImageClickHandler.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * Created by root on 11/3/16. 7 | */ 8 | public interface ImageClickHandler { 9 | void onImageShadeClick(View view); 10 | } 11 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/ImageResult.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | 6 | import java.util.List; 7 | 8 | import proj.me.bitframe.exceptions.FrameException; 9 | 10 | /** 11 | * Created by root on 13/9/16. 12 | */ 13 | 14 | interface ImageResult { 15 | void onImageLoaded(boolean result, Bitmap bitmap, BeanImage beanImage) throws FrameException; 16 | 17 | void setDoneLoading(boolean doneLoading); 18 | 19 | FrameModel getFrameModel(); 20 | 21 | ImageCallback getImageCallback(); 22 | 23 | int getTotalImages(); 24 | 25 | Context getContext(); 26 | 27 | void updateCounter(); 28 | 29 | int getCounter(); 30 | 31 | void callNextCycle(String lastImagePath); 32 | 33 | void handleTransformedResult(Bitmap bitmap, BeanImage beanImage); 34 | 35 | List getImages(); 36 | } 37 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/ImageScrollParcelable.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | /** 10 | * Created by Deepak.Tiwari on 02-12-2015. 11 | */ 12 | class ImageScrollParcelable implements Parcelable{ 13 | 14 | ImageType imageType; 15 | int imagePosition; 16 | String imageLink; 17 | 18 | public ImageType getImageType() { 19 | return imageType; 20 | } 21 | 22 | public void setImageType(ImageType imageType) { 23 | this.imageType = imageType; 24 | } 25 | 26 | public int getImagePosition() { 27 | return imagePosition; 28 | } 29 | 30 | public void setImagePosition(int imagePosition) { 31 | this.imagePosition = imagePosition; 32 | } 33 | 34 | public String getImageLink() { 35 | return imageLink; 36 | } 37 | 38 | public void setImageLink(String imageLink) { 39 | this.imageLink = imageLink; 40 | } 41 | 42 | public ImageScrollParcelable(){} 43 | protected ImageScrollParcelable(Parcel in) { 44 | readFromParcel(in); 45 | } 46 | 47 | public static final Creator CREATOR = new Creator() { 48 | @Override 49 | public ImageScrollParcelable createFromParcel(Parcel in) { 50 | return new ImageScrollParcelable(in); 51 | } 52 | 53 | @Override 54 | public ImageScrollParcelable[] newArray(int size) { 55 | return new ImageScrollParcelable[size]; 56 | } 57 | }; 58 | 59 | @Override 60 | public int describeContents() { 61 | return 0; 62 | } 63 | 64 | @Override 65 | public void writeToParcel(Parcel parcel, int i) { 66 | parcel.writeValue(imageType); 67 | parcel.writeInt(imagePosition); 68 | parcel.writeString(imageLink); 69 | } 70 | private void readFromParcel(Parcel in){ 71 | imageType = (ImageType)in.readValue(getClass().getClassLoader()); 72 | imagePosition = in.readInt(); 73 | imageLink = in.readString(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/ImageShades.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.graphics.Bitmap; 4 | import androidx.palette.graphics.Palette; 5 | import android.view.View; 6 | 7 | import com.squareup.picasso.Picasso; 8 | 9 | import java.lang.ref.SoftReference; 10 | import java.lang.ref.WeakReference; 11 | import java.util.List; 12 | 13 | import proj.me.bitframe.exceptions.FrameException; 14 | import proj.me.bitframe.helper.Utils; 15 | 16 | /** 17 | * Created by root on 23/9/16. 18 | */ 19 | 20 | public abstract class ImageShades implements ImageClickHandler{ 21 | ImageCallback imageCallback; 22 | void setImageCallback(ImageCallback imageCallback){ 23 | this.imageCallback = imageCallback; 24 | } 25 | 26 | boolean result; 27 | void setResult(boolean result){ 28 | this.result = result; 29 | } 30 | 31 | protected boolean getResult(){ 32 | return result; 33 | } 34 | 35 | Picasso currentFramePicasso; 36 | 37 | protected Picasso getCurrentFramePicasso() { 38 | return currentFramePicasso; 39 | } 40 | 41 | void setCurrentFramePicasso(Picasso currentFramePicasso) { 42 | this.currentFramePicasso = currentFramePicasso; 43 | } 44 | 45 | protected void addImageView(View view, int viewWidth, int viewHeight, boolean hasAddInLayout) { 46 | imageCallback.addImageView(view, viewWidth, viewHeight, hasAddInLayout); 47 | } 48 | 49 | protected void imageClicked(ImageType imageType, int imagePosition, String imageLink) { 50 | imageCallback.imageClicked(imageType, imagePosition, imageLink); 51 | } 52 | 53 | protected void setColorsToAddMoreView(int resultColor, int mixedColor, int invertedColor) { 54 | imageCallback.setColorsToAddMoreView(resultColor, mixedColor, invertedColor); 55 | } 56 | 57 | protected void frameResult(BeanBitFrame... beanBitFrames) { 58 | imageCallback.frameResult(beanBitFrames); 59 | } 60 | 61 | protected void addMore() { 62 | imageCallback.addMore(); 63 | } 64 | 65 | protected abstract void updateFrameUi(List images, List beanImages, boolean hasImageProperties) throws FrameException; 66 | protected abstract void onPaletteGenerated(Palette palette, int viewId) throws FrameException; 67 | 68 | public static class PaletteListener implements Palette.PaletteAsyncListener{ 69 | int viewId; 70 | WeakReference imageShadesSoftReference; 71 | public PaletteListener(int viewId, ImageShades imageShades){ 72 | this.viewId = viewId; 73 | imageShadesSoftReference = new WeakReference<>(imageShades); 74 | } 75 | @Override 76 | public void onGenerated(Palette palette) { 77 | ImageShades imageShades = imageShadesSoftReference.get(); 78 | if(imageShades == null) return; 79 | try { 80 | imageShades.onPaletteGenerated(palette, viewId); 81 | } catch (FrameException e) { 82 | e.printStackTrace(); 83 | } 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/ImageType.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | /** 4 | * Created by Deepak.Tiwari on 16-09-2015. 5 | */ 6 | public enum ImageType { 7 | VIEW_NONE(0), 8 | VIEW_SINGLE(1), 9 | VIEW_DOUBLE(2), 10 | VIEW_TRIPLE_1(3), 11 | VIEW_TRIPLE_2(4), 12 | VIEW_TRIPLE_3(5), 13 | VIEW_MULTIPLE_1(6), 14 | VIEW_MULTIPLE_2(7), 15 | VIEW_MULTIPLE_3(8); 16 | ImageType(int value){} 17 | } 18 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/PaletteListener.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.graphics.Color; 4 | import androidx.palette.graphics.Palette; 5 | import java.lang.ref.WeakReference; 6 | 7 | final class PaletteListener implements Palette.PaletteAsyncListener { 8 | WeakReference imageResultSoftReference; 9 | BeanBitFrame beanBitFrame; 10 | BeanImage beanImage; 11 | boolean shouldCallNextCycle; 12 | 13 | PaletteListener(ImageResult imageResult, BeanBitFrame beanBitFrame, BeanImage beanImage, boolean shouldCallNextCycle) { 14 | imageResultSoftReference = new WeakReference<>(imageResult); 15 | this.beanBitFrame = beanBitFrame; 16 | this.beanImage = beanImage; 17 | this.shouldCallNextCycle = shouldCallNextCycle; 18 | } 19 | 20 | @Override 21 | public void onGenerated(Palette palette) { 22 | ImageResult imageResult = imageResultSoftReference.get(); 23 | if (imageResult == null) return; 24 | 25 | int defaultColor = Color.parseColor("#ffffffff"); 26 | Palette.Swatch vibrantSwatch = palette.getVibrantSwatch(); 27 | Palette.Swatch mutedSwatch = palette.getMutedSwatch(); 28 | int vibrantPopulation = vibrantSwatch == null ? 0 : vibrantSwatch.getPopulation(); 29 | int mutedPopulation = mutedSwatch == null ? 0 : mutedSwatch.getPopulation(); 30 | 31 | int vibrantColor = palette.getVibrantColor(defaultColor); 32 | int mutedColor = palette.getMutedColor(defaultColor); 33 | 34 | beanBitFrame.setHasGreaterVibrantPopulation(vibrantPopulation > mutedPopulation); 35 | beanBitFrame.setMutedColor(mutedColor); 36 | beanBitFrame.setVibrantColor(vibrantColor); 37 | 38 | beanBitFrame.setImageComment(beanImage.getImageComment()); 39 | beanBitFrame.setImageLink(beanImage.getImageLink()); 40 | beanBitFrame.setPrimaryCount(beanImage.getPrimaryCount()); 41 | beanBitFrame.setSecondaryCount(beanImage.getSecondaryCount()); 42 | 43 | imageResult.getImageCallback().frameResult(beanBitFrame); 44 | 45 | //without this memory fluctuates more but cpu usage are less 46 | /*Utils.logVerbose("exppp pallet width " + bitmap.getWidth() + " height " + bitmap.getHeight()); 47 | if (!bitmap.isRecycled()) bitmap.recycle();*/ 48 | //also because if view frame fails in hash code then also we are not recycling bitmaps 49 | 50 | if(shouldCallNextCycle) imageResult.callNextCycle(null); 51 | } 52 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/ScaleTransformation.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import com.squareup.picasso.Transformation; 6 | 7 | import java.lang.ref.SoftReference; 8 | import java.lang.ref.WeakReference; 9 | 10 | import proj.me.bitframe.exceptions.FrameException; 11 | import proj.me.bitframe.helper.Utils; 12 | 13 | /** 14 | * Created by root on 15/9/16. 15 | */ 16 | 17 | class ScaleTransformation implements Transformation { 18 | float containerWidth; 19 | float containerHeight; 20 | int totalImage; 21 | String key; 22 | BeanImage beanImage; 23 | WeakReference imageResultSoftReference; 24 | 25 | ScaleTransformation(float containerWidth, float containerHeight, int totalImage, String key, BeanImage beanImage, ImageResult imageResult){ 26 | this.containerWidth = containerWidth; 27 | this.containerHeight = containerHeight; 28 | this.totalImage = totalImage; 29 | this.key = key; 30 | this.beanImage = beanImage; 31 | imageResultSoftReference = new WeakReference<>(imageResult); 32 | } 33 | @Override 34 | public Bitmap transform(Bitmap source) { 35 | totalImage = totalImage > 4 ? 4 : totalImage; 36 | Utils.logVerbose("transforming w : "+source.getWidth()+" h : "+source.getHeight()); 37 | Bitmap target = null; 38 | try { 39 | target = Utils.getScaledBitmap(source, 40 | (int)(containerWidth/(totalImage > 1 ? totalImage - 0.4f : 1)), 41 | (int)(containerHeight/(totalImage > 1 ? totalImage - 0.4f : 1))); 42 | } catch (FrameException e) { 43 | e.printStackTrace(); 44 | } 45 | boolean isNotEqual = false; 46 | if(isNotEqual = target != source) source.recycle(); 47 | 48 | ImageResult imageResult = imageResultSoftReference.get(); 49 | 50 | if(imageResult == null) return target; 51 | 52 | if(isNotEqual) imageResult.handleTransformedResult(target, beanImage); 53 | 54 | return isNotEqual ? Bitmap.createBitmap(1, 1, Bitmap.Config.RGB_565) : target; 55 | } 56 | 57 | 58 | 59 | @Override 60 | public String key() { 61 | return "square"; 62 | } 63 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/UnframedLocalTask.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.os.AsyncTask; 4 | import androidx.palette.graphics.Palette; 5 | 6 | import java.lang.ref.WeakReference; 7 | 8 | import java.lang.ref.SoftReference; 9 | import java.lang.ref.WeakReference; 10 | 11 | import proj.me.bitframe.exceptions.FrameException; 12 | import proj.me.bitframe.helper.BeanResult; 13 | import proj.me.bitframe.helper.Utils; 14 | 15 | /** 16 | * Created by root on 13/9/16. 17 | */ 18 | 19 | class UnframedLocalTask extends AsyncTask { 20 | WeakReference imageResultSoftReference; 21 | 22 | UnframedLocalTask(ImageResult imageResult){ 23 | imageResultSoftReference = new WeakReference<>(imageResult); 24 | } 25 | @Override 26 | protected BeanResult doInBackground(BeanImage... params) { 27 | ImageResult imageResult = imageResultSoftReference.get(); 28 | if(imageResult == null) return null; 29 | 30 | BeanImage beanImage = params[0]; 31 | BeanResult beanResult = null; 32 | float totalImage = imageResult.getTotalImages() > 4 ? 4 : imageResult.getTotalImages(); 33 | try { 34 | beanResult = Utils.decodeBitmapFromPath( 35 | (int)(imageResult.getFrameModel().getMaxContainerWidth()/(totalImage > 1 ? totalImage - 0.4f : 1)), 36 | (int)(imageResult.getFrameModel().getMaxContainerHeight()/(totalImage > 1 ? totalImage - 0.4f : 1)), 37 | beanImage.getImageLink(), imageResult.getContext()); 38 | } catch (FrameException e) { 39 | e.printStackTrace(); 40 | } 41 | if(beanResult == null) beanResult = new BeanResult(); 42 | beanResult.setBeanImage(beanImage); 43 | return beanResult; 44 | } 45 | 46 | @Override 47 | protected void onPostExecute(final BeanResult beanResult) { 48 | super.onPostExecute(beanResult); 49 | 50 | final ImageResult imageResult = imageResultSoftReference.get(); 51 | if(imageResult == null || beanResult == null) return; 52 | 53 | if(beanResult.getBitmap() == null){ 54 | boolean doneLoading = imageResult.getCounter() == (imageResult.getFrameModel().getMaxFrameCount() 55 | >= imageResult.getTotalImages() ? imageResult.getTotalImages() 56 | : imageResult.getFrameModel().getMaxFrameCount()) - 1; 57 | if(doneLoading) imageResult.updateCounter(); 58 | imageResult.setDoneLoading(doneLoading); 59 | try { 60 | imageResult.onImageLoaded(false, null, beanResult.getBeanImage()); 61 | } catch (FrameException e) { 62 | e.printStackTrace(); 63 | } 64 | 65 | //pass this directly to container as it has no result 66 | BeanBitFrame beanBitFrame = new BeanBitFrame(); 67 | imageResult.getImageCallback().frameResult(beanBitFrame); 68 | 69 | Utils.logVerbose("Came image failed -> "+imageResult.getCounter()); 70 | imageResult.callNextCycle(null); 71 | return; 72 | } 73 | if(imageResult.getCounter() >= imageResult.getFrameModel().getMaxFrameCount()){ 74 | imageResult.updateCounter(); 75 | final BeanBitFrame beanBitFrame = new BeanBitFrame(); 76 | beanBitFrame.setWidth(beanResult.getWidth()); 77 | beanBitFrame.setHeight(beanResult.getHeight()); 78 | beanBitFrame.setLoaded(true); 79 | Palette.from(beanResult.getBitmap()).generate(new PaletteListener(imageResult, beanBitFrame, beanResult.getBeanImage(), true)); 80 | }else { 81 | boolean doneLoading = imageResult.getCounter() == (imageResult.getFrameModel().getMaxFrameCount() 82 | >= imageResult.getTotalImages() ? imageResult.getTotalImages() 83 | : imageResult.getFrameModel().getMaxFrameCount()) - 1; 84 | imageResult.setDoneLoading(doneLoading); 85 | try { 86 | imageResult.onImageLoaded(true, beanResult.getBitmap(), beanResult.getBeanImage()); 87 | } catch (FrameException e) { 88 | e.printStackTrace(); 89 | } 90 | imageResult.updateCounter(); 91 | imageResult.callNextCycle(null); 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/UnframedPicassoTarget.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Color; 5 | import android.graphics.drawable.Drawable; 6 | import androidx.palette.graphics.Palette; 7 | 8 | import com.squareup.picasso.Picasso; 9 | import com.squareup.picasso.Target; 10 | 11 | import java.util.List; 12 | 13 | import proj.me.bitframe.exceptions.FrameException; 14 | import proj.me.bitframe.helper.Utils; 15 | 16 | /** 17 | * Created by root on 13/9/16. 18 | */ 19 | 20 | class UnframedPicassoTarget implements Target { 21 | BeanImage beanImage; 22 | boolean doneLoading; 23 | ImageResult imageResult; 24 | List targets; 25 | 26 | UnframedPicassoTarget(BeanImage beanImage, List targets, ImageResult imageResult) { 27 | this.beanImage = beanImage; 28 | this.imageResult = imageResult; 29 | this.targets = targets; 30 | } 31 | 32 | @Override 33 | public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) { 34 | targets.remove(this); 35 | 36 | /*float totalImage = imageResult.getTotalImages() > 4 ? 4 : imageResult.getTotalImages(); 37 | 38 | BeanBitmapResult beanBitmapResult = Utils.getScaledResult(bitmap, 39 | (int)(imageResult.getFrameModel().getMaxContainerWidth()/(totalImage > 1 ? totalImage - 0.4f : 1)), 40 | (int)(imageResult.getFrameModel().getMaxContainerHeight()/(totalImage > 1 ? totalImage - 0.4f : 1)));*/ 41 | 42 | /*BeanBitmapResult beanBitmapResult = new BeanBitmapResult(); 43 | beanBitmapResult.setHeight(bitmap.getHeight()); 44 | beanBitmapResult.setWidth(bitmap.getWidth()); 45 | beanBitmapResult.setBitmap(bitmap);*/ 46 | 47 | if(imageResult.getCounter() >= imageResult.getFrameModel().getMaxFrameCount()){ 48 | imageResult.updateCounter(); 49 | final BeanBitFrame beanBitFrame = new BeanBitFrame(); 50 | beanBitFrame.setWidth(/*beanBitmapResult.getWidth()*/bitmap.getWidth()); 51 | beanBitFrame.setHeight(/*beanBitmapResult.getHeight()*/bitmap.getHeight()); 52 | beanBitFrame.setLoaded(true); 53 | Palette.from(/*beanBitmapResult.getBitmap()*/bitmap).generate(new Palette.PaletteAsyncListener() { 54 | @Override 55 | public void onGenerated(Palette palette) { 56 | /*int defaultColor = Color.parseColor("#ffffffff"); 57 | beanBitFrame.setVibrantColor(palette.getVibrantColor(defaultColor)); 58 | beanBitFrame.setMutedColor(palette.getMutedColor(defaultColor)); 59 | imageResult.getImageCallback().frameResult(beanBitFrame); 60 | bitmap.recycle(); 61 | Utils.logVerbose("loading new image after recycle"); 62 | imageResult.callNextCycle(beanImage.getImageLink());*/ 63 | 64 | int defaultColor = Color.parseColor("#ffffffff"); 65 | Palette.Swatch vibrantSwatch = palette.getVibrantSwatch(); 66 | Palette.Swatch mutedSwatch = palette.getMutedSwatch(); 67 | int vibrantPopulation = vibrantSwatch == null ? 0 : vibrantSwatch.getPopulation(); 68 | int mutedPopulation = mutedSwatch == null ? 0 : mutedSwatch.getPopulation(); 69 | 70 | int vibrantColor = palette.getVibrantColor(defaultColor); 71 | int mutedColor = palette.getMutedColor(defaultColor); 72 | 73 | beanBitFrame.setHasGreaterVibrantPopulation(vibrantPopulation > mutedPopulation); 74 | beanBitFrame.setMutedColor(mutedColor); 75 | beanBitFrame.setVibrantColor(vibrantColor); 76 | 77 | beanBitFrame.setImageComment(beanImage.getImageComment()); 78 | beanBitFrame.setImageLink(beanImage.getImageLink()); 79 | beanBitFrame.setPrimaryCount(beanImage.getPrimaryCount()); 80 | beanBitFrame.setSecondaryCount(beanImage.getSecondaryCount()); 81 | 82 | imageResult.getImageCallback().frameResult(beanBitFrame); 83 | if(!bitmap.isRecycled()) bitmap.recycle(); 84 | Utils.logVerbose("loading new image after recycle"); 85 | imageResult.callNextCycle(beanImage.getImageLink()); 86 | } 87 | }); 88 | }else { 89 | doneLoading = imageResult.getCounter() == (imageResult.getFrameModel().getMaxFrameCount() 90 | >= imageResult.getTotalImages() ? imageResult.getTotalImages() : imageResult.getFrameModel().getMaxFrameCount()) - 1; 91 | imageResult.setDoneLoading(doneLoading); 92 | try { 93 | imageResult.onImageLoaded(true, /*beanBitmapResult.getBitmap()*/bitmap, beanImage); 94 | } catch (FrameException e) { 95 | e.printStackTrace(); 96 | } 97 | imageResult.updateCounter(); 98 | Utils.logVerbose("loading new image"); 99 | imageResult.callNextCycle(beanImage.getImageLink()); 100 | } 101 | Utils.logMessage("Came image loaded -> "+imageResult.getCounter()); 102 | } 103 | 104 | @Override 105 | public void onBitmapFailed(Drawable errorDrawable) { 106 | targets.remove(this); 107 | /*if(doneLoading)*/ imageResult.updateCounter(); 108 | try { 109 | imageResult.onImageLoaded(false, null, beanImage); 110 | } catch (FrameException e) { 111 | e.printStackTrace(); 112 | } 113 | 114 | //pass this directly to container as it has no result 115 | BeanBitFrame beanBitFrame = new BeanBitFrame(); 116 | imageResult.getImageCallback().frameResult(beanBitFrame); 117 | 118 | Utils.logVerbose("Came image failed -> "+imageResult.getCounter()); 119 | imageResult.callNextCycle(null); 120 | } 121 | 122 | @Override 123 | public void onPrepareLoad(Drawable placeHolderDrawable) { 124 | } 125 | 126 | @Override 127 | public boolean equals(Object o) { 128 | return this.beanImage.getImageLink().equals(((UnframedPicassoTarget)o).beanImage.getImageLink()); 129 | } 130 | 131 | @Override 132 | public int hashCode() { 133 | return targets.size() + 1; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/UnframedPicassoTargetNew.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.drawable.Drawable; 5 | import android.text.TextUtils; 6 | 7 | import com.squareup.picasso.Picasso; 8 | import com.squareup.picasso.Target; 9 | 10 | import java.lang.ref.SoftReference; 11 | import java.lang.ref.WeakReference; 12 | import java.util.List; 13 | 14 | import proj.me.bitframe.exceptions.FrameException; 15 | import proj.me.bitframe.helper.Utils; 16 | 17 | /** 18 | * Created by root on 13/9/16. 19 | */ 20 | 21 | class UnframedPicassoTargetNew implements Target { 22 | WeakReference imageResultSoftReference; 23 | BeanImage beanImage; 24 | 25 | UnframedPicassoTargetNew(ImageResult imageResult, BeanImage beanImage) { 26 | imageResultSoftReference = new WeakReference<>(imageResult); 27 | this.beanImage = beanImage; 28 | } 29 | 30 | @Override 31 | public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { 32 | ImageResult imageResult = imageResultSoftReference.get(); 33 | if (imageResult == null) return; 34 | Utils.logMessage("Came image loaded -> " + imageResult.getCounter() + " bit width = " + bitmap.getWidth() + " height " + bitmap.getHeight()); 35 | imageResult.callNextCycle(beanImage.getImageLink()); 36 | imageResult.handleTransformedResult(bitmap, bitmap.getWidth() > 1 ? beanImage : null); 37 | } 38 | 39 | @Override 40 | public void onBitmapFailed(Drawable errorDrawable) { 41 | ImageResult imageResult = imageResultSoftReference.get(); 42 | if (imageResult == null) return; 43 | boolean doneLoading = imageResult.getCounter() == (imageResult.getFrameModel().getMaxFrameCount() 44 | >= imageResult.getTotalImages() ? imageResult.getTotalImages() 45 | : imageResult.getFrameModel().getMaxFrameCount()) - 1; 46 | if (doneLoading) imageResult.updateCounter(); 47 | imageResult.setDoneLoading(doneLoading); 48 | try { 49 | imageResult.onImageLoaded(false, null, beanImage); 50 | } catch (FrameException e) { 51 | e.printStackTrace(); 52 | } 53 | 54 | //pass this directly to container as it has no result 55 | BeanBitFrame beanBitFrame = new BeanBitFrame(); 56 | imageResult.getImageCallback().frameResult(beanBitFrame); 57 | 58 | Utils.logVerbose("Came image failed -> " + imageResult.getCounter()); 59 | imageResult.callNextCycle(null); 60 | } 61 | 62 | @Override 63 | public void onPrepareLoad(Drawable placeHolderDrawable) { 64 | //for placeholder 65 | } 66 | 67 | @Override 68 | public boolean equals(Object o) { 69 | if (o == this) return true; 70 | if (!(o instanceof UnframedPicassoTargetNew)) return false; 71 | BeanImage beanImageTarget = ((UnframedPicassoTargetNew) o).beanImage; 72 | return beanImage.getImageLink().equals(beanImageTarget.getImageLink()) 73 | && (beanImage.getImageComment() == null || beanImage.getImageComment().equals(beanImageTarget.getImageComment())) 74 | && beanImage.getPrimaryCount() == beanImageTarget.getPrimaryCount() 75 | && beanImage.getSecondaryCount() == beanImageTarget.getSecondaryCount(); 76 | } 77 | 78 | @Override 79 | public int hashCode() { 80 | int result = beanImage.getPrimaryCount() + beanImage.getSecondaryCount(); 81 | result = result <= 0 ? 17 : result; 82 | 83 | //result = 31 * result + beanImage.hashCode(); -- because bean image properties needs to to checked not bean image itself 84 | result = 31 * result + beanImage.getImageLink().hashCode(); 85 | if (beanImage.getImageComment() != null) 86 | result = 31 * result + beanImage.getImageComment().hashCode(); 87 | result = 31 * result + beanImage.getPrimaryCount(); 88 | result = 31 * result + beanImage.getSecondaryCount(); 89 | 90 | return result; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/dimentions/BeanShade1.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.dimentions; 2 | 3 | /** 4 | * Created by root on 23/3/16. 5 | */ 6 | public class BeanShade1 { 7 | private int width1; 8 | private int height1; 9 | 10 | public int getHeight1() { 11 | return height1; 12 | } 13 | 14 | public void setHeight1(int height1) { 15 | this.height1 = height1; 16 | } 17 | 18 | public int getWidth1() { 19 | return width1; 20 | } 21 | 22 | public void setWidth1(int width1) { 23 | this.width1 = width1; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/dimentions/BeanShade2.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.dimentions; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by root on 23/3/16. 7 | */ 8 | public class BeanShade2 extends BeanShade1{ 9 | private List imageOrderList; 10 | private LayoutType layoutType; 11 | private int width2; 12 | private int height2; 13 | 14 | private boolean addInLayout; 15 | 16 | public boolean isAddInLayout() { 17 | return addInLayout; 18 | } 19 | 20 | public void setAddInLayout(boolean addInLayout) { 21 | this.addInLayout = addInLayout; 22 | } 23 | 24 | public LayoutType getLayoutType() { 25 | return layoutType; 26 | } 27 | 28 | public void setLayoutType(LayoutType layoutType) { 29 | this.layoutType = layoutType; 30 | } 31 | 32 | public List getImageOrderList() { 33 | return imageOrderList; 34 | } 35 | 36 | public void setImageOrderList(List imageOrderList) { 37 | this.imageOrderList = imageOrderList; 38 | } 39 | 40 | public int getWidth2() { 41 | return width2; 42 | } 43 | 44 | public void setWidth2(int width2) { 45 | this.width2 = width2; 46 | } 47 | 48 | public int getHeight2() { 49 | return height2; 50 | } 51 | 52 | public void setHeight2(int height2) { 53 | this.height2 = height2; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/dimentions/BeanShade3.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.dimentions; 2 | 3 | /** 4 | * Created by root on 27/3/16. 5 | */ 6 | public class BeanShade3 extends BeanShade2{ 7 | private int width3; 8 | private int height3; 9 | 10 | public int getWidth3() { 11 | return width3; 12 | } 13 | 14 | public void setWidth3(int width3) { 15 | this.width3 = width3; 16 | } 17 | 18 | public int getHeight3() { 19 | return height3; 20 | } 21 | 22 | public void setHeight3(int height3) { 23 | this.height3 = height3; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/dimentions/BeanShade4.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.dimentions; 2 | 3 | /** 4 | * Created by root on 6/4/16. 5 | */ 6 | public class BeanShade4 extends BeanShade3{ 7 | private int width4; 8 | private int height4; 9 | 10 | public int getWidth4() { 11 | return width4; 12 | } 13 | 14 | public void setWidth4(int width4) { 15 | this.width4 = width4; 16 | } 17 | 18 | public int getHeight4() { 19 | return height4; 20 | } 21 | 22 | public void setHeight4(int height4) { 23 | this.height4 = height4; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/dimentions/ImageOrder.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.dimentions; 2 | 3 | /** 4 | * Created by root on 27/3/16. 5 | */ 6 | public enum ImageOrder { 7 | FIRST, 8 | SECOND, 9 | THIRD, 10 | FOURTH 11 | } 12 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/dimentions/LayoutType.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.dimentions; 2 | 3 | /** 4 | * Created by root on 27/3/16. 5 | */ 6 | public enum LayoutType { 7 | PARALLEL_HORZ, 8 | PARALLEL_VERT, 9 | HORZ, 10 | VERT, 11 | IDENTICAL_VARY_WIDTH, 12 | IDENTICAL_VARY_HEIGHT, 13 | VERT_HORZ, 14 | HORZ_VERT, 15 | VERT_DOUBLE, 16 | HORZ_DOUBLE 17 | } 18 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/exceptions/FrameException.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.exceptions; 2 | 3 | import android.text.TextUtils; 4 | 5 | import proj.me.bitframe.helper.Utils; 6 | 7 | /** 8 | * Created by root on 29/9/16. 9 | */ 10 | 11 | public class FrameException extends Exception{ 12 | public FrameException(String message){ 13 | super(message); 14 | Utils.logVerbose(message); 15 | } 16 | 17 | public FrameException(String message, Throwable throwable){ 18 | super(message, throwable); 19 | Utils.logVerbose(message); 20 | } 21 | 22 | public FrameException(Throwable throwable){ 23 | super(throwable); 24 | String message = throwable.getMessage(); 25 | if(!TextUtils.isEmpty(message)) Utils.logVerbose(message); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/frames/FrameHelper.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.frames; 2 | 3 | /** 4 | * Created by root on 20/7/17. 5 | */ 6 | public class FrameHelper { 7 | 8 | static class Frame{ 9 | Image[] images; int cImg; int frameAvl; int rowAvl; int colAvl; int cFrm; int xW; int xH; int restc; 10 | } 11 | static class Image{ 12 | int width; 13 | int height; 14 | String name; 15 | Image(int width, int height, String name){ 16 | this.width = width; 17 | this.height = height; 18 | this.name = name; 19 | } 20 | } 21 | //can contain max 4 images 22 | static class Dimen{ 23 | Image[] images; 24 | int last = 0; 25 | Dimen(int count){ 26 | if(count > 4) count = 4; 27 | images = new Image[count]; 28 | } 29 | void add(Image image){ 30 | images[last++] = image; 31 | } 32 | } 33 | 34 | int m, x, y, z; 35 | Dimen[] dimen; 36 | public FrameHelper(int m, int x, int y, int z){ 37 | this.m = m; 38 | this.x = x; 39 | this.y = y; 40 | this.z = z; 41 | dimen = new Dimen[6]; 42 | } 43 | 44 | //priority -> HF, VF, HH, VH, HT, VT 45 | private void create(Image[] images, int cImg, int frameAvl, int rowAvl, int colAvl, int cFrm, int xW, int xH, int restc){ 46 | int imageCount = images.length - cImg; 47 | if(imageCount == 0) return; 48 | if(imageCount > 0 && frameAvl == 0 || xW <= 0 || xH <= 0){ 49 | System.out.println("failed"); 50 | return; 51 | } 52 | 53 | int index = 0; 54 | boolean isFramed = false; 55 | //HF and other 3 -> 0100 = 4 56 | if((restc ^ (4 << (24 - 4 * index++))) > 0){ 57 | 58 | } 59 | //VF and other 3 -> 1100 = 12 60 | if(!isFramed && (restc ^ (12 << (24 - 4 * index++))) > 0){ 61 | 62 | } 63 | //HH -> 0010 = 2 64 | if(!isFramed && (restc ^ (2 << (24 - 4 * index++))) > 0){ 65 | 66 | } 67 | //VH -> 1010 = 10 68 | if(!isFramed && (restc ^ (10 << (24 - 4 * index++))) > 0){ 69 | 70 | } 71 | //HT -> 0001 = 1 72 | if(!isFramed && (restc ^ (1 << (24 - 4 * index++))) > 0){ 73 | 74 | } 75 | //VT -> 1001 = 9 76 | if(!isFramed && (restc ^ (9 << (24 - 4 * index))) > 0){ 77 | 78 | } 79 | 80 | //append restriction for next step 81 | //restriction 24 bit -> HF, VF, HH, VH, HT, VT 82 | } 83 | 84 | 85 | private Frame typeHF(Image[] images, int cImg, int frameAvl, int rowAvl, int colAvl, int cFrm, int xW, int xH, int restc){ 86 | int imageCount = images.length - cImg; 87 | 88 | 89 | 90 | return new Frame(); 91 | } 92 | 93 | 94 | private void createFrame(Image[] images, int index, Node root, int remainXW, int remainYH, int remainZW, int remainZH){ 95 | 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/frames/IndexQueue.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.frames; 2 | 3 | /** 4 | * Created by root on 22/7/17. 5 | */ 6 | public class IndexQueue { 7 | private T[] array; 8 | 9 | private int front = -1; 10 | private int rear = -1; 11 | 12 | public IndexQueue(int size){ 13 | array = (T[])new Object[size]; 14 | } 15 | 16 | public boolean enqueue(T node){ 17 | int index = (front + 1) % array.length; 18 | if(index == rear) return false; 19 | array[index] = node; 20 | front = index; 21 | if(rear == -1) rear = index; 22 | return true; 23 | } 24 | 25 | public T dequeue(){ 26 | if(rear == -1) return null; 27 | T obj = array[rear]; 28 | array[rear] = null; 29 | if(rear == front){ 30 | front = -1; 31 | rear = -1; 32 | }else rear = (rear + 1) % array.length; 33 | 34 | return obj; 35 | } 36 | 37 | public T peak(){ 38 | if(front == -1) return null; 39 | return array[front]; 40 | } 41 | 42 | public T itemAt(int index){ 43 | if(index >= array.length) return null; 44 | return array[index]; 45 | } 46 | 47 | public boolean isEmpty(){ 48 | return front == -1; 49 | } 50 | 51 | public int currentFront(){ 52 | return front; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/frames/Node.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.frames; 2 | 3 | import java.util.HashMap; 4 | import java.util.HashSet; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | public class Node { 9 | 10 | private int type; 11 | private Node[] subTypes; 12 | private int size; 13 | 14 | private boolean isRepeated; 15 | private int row; 16 | private int col; 17 | private int repeatSize; 18 | private Map> subMatrixMap; 19 | 20 | Node(int type) { 21 | this.type = type; 22 | subTypes = new Node[8]; 23 | subMatrixMap = new HashMap<>(); 24 | assignRowAndCol(type); 25 | } 26 | 27 | Node setSubType(int type) { 28 | subTypes[size++] = new Node(type); 29 | return subTypes[size - 1]; 30 | } 31 | 32 | void deleteSubType() { 33 | subTypes[--size] = null; 34 | } 35 | 36 | public void insertMatrixType() { 37 | int index = 0; 38 | 39 | while (index < subTypes.length) { 40 | if(subTypes[index] == null) break; 41 | Set subMatrixSet = new HashSet<>(); 42 | subMatrixSet.addAll(subTypes[index].subMatrixMap.keySet()); 43 | 44 | if(subMatrixSet.size() == 0){ 45 | int subMatrixType = rowColToMatrix(subTypes[index].row, subTypes[index].col); 46 | subMatrixSet.add(subMatrixType); 47 | } 48 | 49 | for (int subMatrixType : subMatrixSet) { 50 | int rowCol = matrixToRowCol(subMatrixType); 51 | int subRow = (rowCol >> 4) << 1; 52 | int subCol = rowCol << 5; 53 | 54 | int max = Math.max(subRow, subCol); 55 | 56 | int newRow = row, newCol = col; 57 | if (max == row) newCol = col + subCol; 58 | else newRow = row + subRow; 59 | int matrixType = rowColToMatrix(newRow, newCol); 60 | SubMatrix subMatrix = new SubMatrix(index, subMatrixType); 61 | if (!subMatrixMap.containsKey(matrixType)) subMatrixMap.put(matrixType, new HashSet()); 62 | subMatrixMap.get(matrixType).add(subMatrix); 63 | } 64 | index++; 65 | } 66 | } 67 | 68 | public boolean setSubRepeating(Node node, int matrixType, Set subMatrixSet){ 69 | if(node.isRepeated || subMatrixSet == null){ 70 | node.isRepeated = true; 71 | return true; 72 | } 73 | 74 | int rowCol = matrixToRowCol(matrixType); 75 | int subRow = (rowCol >> 4) << 1; 76 | int subCol = rowCol << 5; 77 | 78 | int max = Math.max(node.row, node.col); 79 | 80 | if (max == subRow) subCol = subCol - node.col; 81 | else subRow = subRow - node.row; 82 | 83 | matrixType = rowColToMatrix(subRow, subCol); 84 | 85 | SubMatrix subMatrix = null; 86 | for(SubMatrix subMatrix1 : subMatrixSet){ 87 | if(subMatrix1.matrixType == matrixType) { 88 | subMatrix = subMatrix1; 89 | break; 90 | } 91 | } 92 | 93 | if(subMatrix == null) return false; 94 | 95 | Node subNode = node.subTypes[subMatrix.index]; 96 | subMatrixSet = subNode.subMatrixMap.get(matrixType); 97 | if(setSubRepeating(subNode, matrixType, subMatrixSet)){ 98 | node.repeatSize++; 99 | node.isRepeated = node.repeatSize == node.subMatrixMap.size(); 100 | } 101 | 102 | return node.isRepeated; 103 | } 104 | 105 | private int rowColToMatrix(int row, int col){ 106 | int offset = -1; 107 | switch (row) { 108 | case 1: 109 | offset = -1; 110 | break; 111 | case 2: 112 | offset = 3; 113 | break; 114 | case 3: 115 | offset = 7; 116 | break; 117 | case 4: 118 | offset = 11; 119 | break; 120 | } 121 | return 1 << (col + offset); 122 | } 123 | 124 | private int matrixToRowCol(int matrixType){ 125 | int subRow = 0, subCol = 0; 126 | int offset = -1; 127 | 128 | while (subRow <= 4) { 129 | if ((matrixType & (15 << (4 * subRow))) != 0) { 130 | subRow++; 131 | int rowCol = matrixType >> (offset + 1); 132 | while ((rowCol >> subCol) != 1) subCol++; 133 | subCol++; 134 | break; 135 | } 136 | offset += 4; 137 | subRow++; 138 | } 139 | 140 | return ((8 | subRow) << 4) | subCol; 141 | } 142 | 143 | private void assignRowAndCol(int type) { 144 | switch (type) { 145 | case AvailableTypes.HF: 146 | row = 1; 147 | col = 1; 148 | break; 149 | case AvailableTypes.VF: 150 | row = 1; 151 | col = 1; 152 | break; 153 | case AvailableTypes.HH: 154 | row = 1; 155 | col = 2; 156 | break; 157 | case AvailableTypes.VH: 158 | row = 2; 159 | col = 1; 160 | break; 161 | case AvailableTypes.HT: 162 | row = 1; 163 | col = 3; 164 | break; 165 | case AvailableTypes.VT: 166 | row = 3; 167 | col = 1; 168 | break; 169 | case AvailableTypes.HQ: 170 | row = 1; 171 | col = 4; 172 | break; 173 | case AvailableTypes.VQ: 174 | row = 4; 175 | col = 1; 176 | break; 177 | } 178 | } 179 | 180 | public int getType() { 181 | return type; 182 | } 183 | 184 | public Node[] getSubTypes() { 185 | return subTypes; 186 | } 187 | 188 | public Set getMatrixSet(){ 189 | return subMatrixMap.keySet(); 190 | } 191 | public Set getSubMatrixSet(int matrix){ 192 | return subMatrixMap.get(matrix); 193 | } 194 | 195 | private static class SubMatrix { 196 | int index; 197 | int matrixType; 198 | 199 | SubMatrix(int index, int matrixType) { 200 | this.index = index; 201 | this.matrixType = matrixType; 202 | } 203 | } 204 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/frames/tournament/FrameBuilder.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.frames.tournament; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by root on 31/7/17. 7 | */ 8 | public class FrameBuilder { 9 | private int rowUsed; 10 | private int colUsed; 11 | private List frameBundles; 12 | public FrameBuilder(int rowUsed, int colUsed, List frameBundles){ 13 | this.rowUsed = rowUsed; 14 | this.colUsed = colUsed; 15 | this.frameBundles = frameBundles; 16 | } 17 | 18 | public void buildCustomFrame(){ 19 | int minHorzBlock = Utility.upperBound(Utility.upperBound(Utility.MID, colUsed), 2); 20 | int minVertBlock = Utility.upperBound(Utility.upperBound(Utility.MID, rowUsed), 2); 21 | 22 | int[] rowColCovered = new int[2]; 23 | for(int i = frameBundles.size() - 1; i>=0 ; i--) 24 | rowColCovered = frameBundles.get(i).assignCustomDimensions(minHorzBlock, minVertBlock, rowColCovered, 25 | i < frameBundles.size() - 1 ? frameBundles.get(i + 1) : null); 26 | 27 | frameBundles.get(0).changeBlockDimensions(Utility.Z_LENGTH, Utility.Z_LENGTH); 28 | } 29 | 30 | public void buildFixed1Frame(){ 31 | frameBundles.get(0).assignFixed1Dimensions(0, 0, new int[]{0, 0}, frameBundles, 1); 32 | } 33 | 34 | public void buildFixed2Frame(){ 35 | int rowBlockSize = Utility.upperBound(Utility.MID_5Q , colUsed); 36 | int colBlockSize = Utility.upperBound(Utility.MID_5Q , rowUsed); 37 | int[] rowColCovered = new int[2]; 38 | for(int i = frameBundles.size() - 1; i>=0 ; i--) 39 | rowColCovered = frameBundles.get(i).assignFixed2Dimensions(rowBlockSize, colBlockSize, rowColCovered); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/frames/tournament/Picture.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.frames.tournament; 2 | 3 | public class Picture implements Cloneable{ 4 | private int width; 5 | private int height; 6 | private String uri; 7 | private int index; 8 | 9 | public int getWidth() { 10 | return width; 11 | } 12 | 13 | public void setWidth(int width) { 14 | this.width = width; 15 | } 16 | 17 | public int getHeight() { 18 | return height; 19 | } 20 | 21 | public void setHeight(int height) { 22 | this.height = height; 23 | } 24 | 25 | public String getUri() { 26 | return uri; 27 | } 28 | 29 | public void setUri(String uri) { 30 | this.uri = uri; 31 | } 32 | 33 | public int getIndex() { 34 | return index; 35 | } 36 | 37 | public void setIndex(int index) { 38 | this.index = index; 39 | } 40 | 41 | @Override 42 | public boolean equals(Object o) { 43 | Picture p = (Picture)o; 44 | return this.width == p.width && this.height == p.height && this.uri.equals(p.uri) && this.index == p.index; 45 | } 46 | 47 | @Override 48 | public int hashCode() { 49 | int result = 17; 50 | result = 31 * result + width; 51 | result = 31 * result + height; 52 | result = 31 * result + uri.hashCode(); 53 | result = 31 * result + index; 54 | return result; 55 | } 56 | 57 | @Override 58 | protected Object clone() throws CloneNotSupportedException { 59 | return super.clone(); 60 | } 61 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/frames/tournament/RangeBar.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.frames.tournament; 2 | 3 | /** 4 | * Created by root on 27/7/17. 5 | */ 6 | public enum RangeBar { 7 | FIRST(1), 8 | SECOND(2), 9 | THIRD(3), 10 | FOURTH(4), 11 | MID(5), 12 | SIXTH(6), 13 | SEVENTH(7), 14 | EIGHTH(8), 15 | NINTH(9); 16 | 17 | private int range; 18 | RangeBar(int range){ 19 | this.range = range; 20 | } 21 | 22 | public int getRange(){ 23 | return range; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/frames/tournament/TournamentType.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.frames.tournament; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Created by root on 25/7/17. 7 | */ 8 | public class TournamentType { 9 | private static class TournamentLeaves{ 10 | int index = -1; 11 | PictureAttribute[] attrs; 12 | TournamentLeaves(PictureAttribute[] attrs){ 13 | this.attrs = attrs; 14 | index = 0; 15 | } 16 | } 17 | 18 | private int type; 19 | private Builder builder; 20 | 21 | public TournamentType(int type){ 22 | this.type = type; 23 | } 24 | 25 | public Builder build(PictureAttribute[] typeCombinations, int totalTournaments){ 26 | if(builder != null) return builder.reset(); 27 | builder = new Builder(totalTournaments) 28 | .buildTournamentTree(typeCombinations); 29 | return builder; 30 | } 31 | 32 | 33 | public static class Builder{ 34 | private TournamentLeaves[] tournamentLeaves; 35 | private int totalTournaments; 36 | private PictureAttribute[] heap; 37 | private int heapSize; 38 | 39 | private Builder(int totalTournaments){ 40 | this.totalTournaments = totalTournaments; 41 | tournamentLeaves = new TournamentLeaves[totalTournaments]; 42 | } 43 | 44 | public Builder reset(){ 45 | for(TournamentLeaves tournamentLeave : tournamentLeaves) 46 | if(tournamentLeave.index != -1) tournamentLeave.index = 0; 47 | return this; 48 | } 49 | 50 | private Builder buildTournamentTree(PictureAttribute[] typeCombinations){ 51 | int size = typeCombinations.length; 52 | 53 | int comboSize = size / totalTournaments; 54 | 55 | for(int i = totalTournaments - 1;i>=0;i--){ 56 | int length = comboSize < 0 ? 0 : comboSize; 57 | if(length == 0 && i != 0) continue; 58 | else if(i == 0) length = size - comboSize * (totalTournaments - 1); 59 | 60 | PictureAttribute[] combo = Arrays.copyOfRange(typeCombinations, 0, length); 61 | Arrays.sort(combo); 62 | tournamentLeaves[i] = new TournamentLeaves(combo); 63 | } 64 | 65 | int actualLeaves = 1; 66 | while(totalTournaments > actualLeaves) actualLeaves <<= 1; 67 | 68 | heap = new PictureAttribute[actualLeaves + actualLeaves - 1]; 69 | 70 | int leaf = 0; 71 | for(int i = actualLeaves - 1;i< heap.length;i++){ 72 | if(leaf < totalTournaments){ 73 | TournamentLeaves tournamentLeave = tournamentLeaves[leaf]; 74 | if(tournamentLeave.index == -1){ 75 | leaf++; 76 | continue; 77 | } 78 | heap[i] = tournamentLeave.attrs[tournamentLeave.index++]; 79 | heapSize++; 80 | leaf++; 81 | }else break; 82 | } 83 | 84 | heapSize += actualLeaves - 1; 85 | 86 | for(int i = actualLeaves - 1;i >= 0;i--) buildMaxHeap(i); 87 | 88 | return this; 89 | } 90 | 91 | private void buildMaxHeap(int index){ 92 | if(index >= heapSize || index < 0) return; 93 | int left = index * 2 + 1; 94 | int right = index * 2 + 2; 95 | 96 | int position = index; 97 | if(left < heapSize && heap[left].compareTo(heap[position]) == 1) position = left; 98 | if(right < heapSize && heap[right].compareTo(heap[position]) == 1) position = right; 99 | 100 | if(position == index) return; 101 | 102 | PictureAttribute temp = heap[position]; 103 | heap[position] = heap[index]; 104 | heap[index] = temp; 105 | 106 | index = heap.length >> 1; 107 | if(position >= index && heap[position] == null){ 108 | index = position - index; 109 | TournamentLeaves tournamentLeave = tournamentLeaves[index]; 110 | if(tournamentLeave.index > -1 && tournamentLeave.index < tournamentLeave.attrs.length) 111 | heap[position] = tournamentLeave.attrs[tournamentLeave.index++]; 112 | }else buildMaxHeap(position); 113 | } 114 | 115 | private PictureAttribute extractMax(int indexesUsed){ 116 | if(heapSize == 0) return null; 117 | PictureAttribute pictureAttribute = heap[0]; 118 | heap[0] = heap[heapSize - 1]; 119 | 120 | int index = heap.length >> 1; 121 | if(heapSize - 1 >= index){ 122 | index = heapSize - 1 - index; 123 | 124 | TournamentLeaves tournamentLeave = tournamentLeaves[index]; 125 | if(tournamentLeave.index == -1) heapSize--; 126 | else { 127 | for (; tournamentLeave.index < tournamentLeave.attrs.length; tournamentLeave.index++) 128 | if ((tournamentLeave.attrs[tournamentLeave.index].getIndexes() & indexesUsed) == 0) 129 | break; 130 | 131 | if (tournamentLeave.index < tournamentLeave.attrs.length) { 132 | heap[heapSize - 1] = tournamentLeave.attrs[tournamentLeave.index++]; 133 | } else heapSize--; 134 | } 135 | 136 | }else heapSize--; 137 | 138 | buildMaxHeap(0); 139 | return pictureAttribute; 140 | } 141 | 142 | public PictureAttribute extractNextFrame(int indexesUsed){ 143 | PictureAttribute pictureAttribute = extractMax(indexesUsed); 144 | 145 | while(pictureAttribute != null && (pictureAttribute.getIndexes() & indexesUsed) != 0) 146 | pictureAttribute = extractMax(indexesUsed); 147 | 148 | return pictureAttribute; 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/helper/BeanBitmapResult.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.helper; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import proj.me.bitframe.BeanImage; 6 | 7 | /** 8 | * Created by root on 14/9/16. 9 | */ 10 | 11 | class BeanBitmapResult { 12 | private Bitmap bitmap; 13 | private int width; 14 | private int height; 15 | 16 | public Bitmap getBitmap() { 17 | return bitmap; 18 | } 19 | 20 | public void setBitmap(Bitmap bitmap) { 21 | this.bitmap = bitmap; 22 | } 23 | 24 | public int getWidth() { 25 | return width; 26 | } 27 | 28 | public void setWidth(int width) { 29 | this.width = width; 30 | } 31 | 32 | public int getHeight() { 33 | return height; 34 | } 35 | 36 | public void setHeight(int height) { 37 | this.height = height; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/helper/BeanResult.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.helper; 2 | 3 | 4 | import proj.me.bitframe.BeanImage; 5 | 6 | /** 7 | * Created by root on 13/9/16. 8 | */ 9 | 10 | public class BeanResult extends BeanBitmapResult { 11 | private BeanImage beanImage; 12 | private int inSampleSize; 13 | 14 | public BeanImage getBeanImage() { 15 | return beanImage; 16 | } 17 | 18 | public void setBeanImage(BeanImage beanImage) { 19 | this.beanImage = beanImage; 20 | } 21 | public int getInSampleSize() { 22 | return inSampleSize; 23 | } 24 | 25 | public void setInSampleSize(int inSampleSize) { 26 | this.inSampleSize = inSampleSize; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/helper/ColorCombination.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.helper; 2 | 3 | public enum ColorCombination { 4 | VIBRANT_TO_MUTED(0), 5 | MUTED_TO_VIBRANT(1); 6 | final int colorCombo; 7 | ColorCombination(int colorCombo){ 8 | this.colorCombo = colorCombo; 9 | } 10 | } -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/helper/ColorPallet.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.helper; 2 | 3 | /** 4 | * Created by root on 13/3/16. 5 | */ 6 | public enum ColorPallet { 7 | VIBRANT, 8 | VIBRANT_DARK, 9 | VIBRANT_LIGHT, 10 | 11 | MUTED, 12 | MUTED_DARK, 13 | MUTED_LIGHT 14 | } 15 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/helper/FrameType.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.helper; 2 | 3 | /** 4 | * Created by root on 13/9/16. 5 | * at first UNFRAMED_LOCAL should be used for better bitmap handling to process local images 6 | * UNFRAMED_LOCAL type for all unframed local uri's, use it for local images of higher resolution 7 | * UNFRAMED_MIXED type for mixed type of image uri's local as well as server.it uses piccaso to load images 8 | * FRAMED_MIXED you have all the details about the images 9 | */ 10 | 11 | public enum FrameType { 12 | UNFRAMED, 13 | FRAMED 14 | } 15 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/shading_one/BindingShadeOne.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.shading_one; 2 | 3 | import android.graphics.Bitmap; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.ImageView; 7 | import android.widget.LinearLayout; 8 | import android.widget.TextView; 9 | 10 | import proj.me.bitframe.ImageClickHandler; 11 | import proj.me.bitframe.R; 12 | 13 | 14 | /** 15 | * Created by root on 11/3/16. 16 | */ 17 | public class BindingShadeOne { 18 | 19 | private View root; 20 | private String comment; 21 | 22 | View bind(View root, final ImageClickHandler clickHandler) { 23 | this.root = root; 24 | root.findViewById(R.id.view_single_image).setOnClickListener(new View.OnClickListener() { 25 | @Override 26 | public void onClick(View view) { 27 | clickHandler.onImageShadeClick(view); 28 | } 29 | }); 30 | return root; 31 | } 32 | 33 | public void setImageScaleType(ImageView.ScaleType imageScaleType) { 34 | ImageView imageView = root.findViewById(R.id.view_single_image); 35 | imageView.setScaleType(imageScaleType); 36 | } 37 | 38 | public void setImageBackgroundColor(int imageBackgroundColor) { 39 | ImageView imageView = root.findViewById(R.id.view_single_image); 40 | imageView.setBackgroundColor(imageBackgroundColor); 41 | } 42 | 43 | public void setImageCounterText(String imageCounterText) { 44 | TextView textView = root.findViewById(R.id.counter_text); 45 | textView.setText(imageCounterText); 46 | } 47 | 48 | public void setImageCounterVisibility(boolean imageCounterVisibility) { 49 | LinearLayout linearLayout = root.findViewById(R.id.image_one_counter_container); 50 | linearLayout.setVisibility(imageCounterVisibility ? View.VISIBLE : View.GONE); 51 | } 52 | 53 | public void setShouldCommentVisible(boolean shouldCommentVisible) { 54 | TextView textView = root.findViewById(R.id.comment_text); 55 | textView.setVisibility(shouldCommentVisible ? View.VISIBLE : View.INVISIBLE); 56 | } 57 | 58 | public void setCommentTextBackgroundColor(int commentTextBackgroundColor) { 59 | TextView textView = root.findViewById(R.id.comment_text); 60 | textView.setBackgroundColor(commentTextBackgroundColor); 61 | } 62 | 63 | public String getComment() { 64 | return comment; 65 | } 66 | 67 | public void setComment(String comment) { 68 | this.comment = comment; 69 | TextView textView = root.findViewById(R.id.comment_text); 70 | textView.setText(comment); 71 | } 72 | 73 | public static void setLayoutWidth(View view, int width){ 74 | ViewGroup.LayoutParams params = view.getLayoutParams(); 75 | params.width = width; 76 | view.setLayoutParams(params); 77 | } 78 | 79 | public static void setLayoutHeight(View view, int height){ 80 | ViewGroup.LayoutParams params = view.getLayoutParams(); 81 | params.height = height; 82 | view.setLayoutParams(params); 83 | } 84 | 85 | public static void setBitmap(ImageView view, Bitmap bitmap){ 86 | view.setImageBitmap(bitmap); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /bitframe/src/main/java/proj/me/bitframe/shading_one/ShadeOne.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe.shading_one; 2 | 3 | import proj.me.bitframe.FrameModel; 4 | import proj.me.bitframe.dimentions.BeanShade1; 5 | 6 | /** 7 | * Created by root on 21/3/16. 8 | */ 9 | class ShadeOne { 10 | static BeanShade1 calculateDimentions(FrameModel frameModel, int width, int height){ 11 | BeanShade1 beanShade1 = new BeanShade1(); 12 | float WIDTH_1 = frameModel.isHasFixedDimensions() || width > frameModel.getMaxContainerWidth() ? frameModel.getMaxContainerWidth() : width < frameModel.getMinFrameWidth() ? frameModel.getMinFrameWidth() : width; 13 | float HEIGHT_1 = frameModel.isHasFixedDimensions() || height > frameModel.getMaxContainerHeight() ? frameModel.getMaxContainerHeight() : height < frameModel.getMinFrameHeight() ? frameModel.getMinFrameHeight() : height; 14 | beanShade1.setWidth1((int)WIDTH_1); 15 | beanShade1.setHeight1((int)HEIGHT_1); 16 | return beanShade1; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /bitframe/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/bitframe/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /bitframe/src/main/res/layout/item_imageview.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 10 | 11 | 17 | 18 | 26 | 27 | -------------------------------------------------------------------------------- /bitframe/src/main/res/layout/noscroll_item_imageview.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 13 | 14 | 22 | -------------------------------------------------------------------------------- /bitframe/src/main/res/layout/view_double_horz.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 22 | 23 | 40 | 41 | 42 | 52 | 53 | 60 | 61 | 78 | 79 | 80 | 98 | 99 | 107 | 108 | 109 | 122 | 123 | 131 | 132 | -------------------------------------------------------------------------------- /bitframe/src/main/res/layout/view_double_vert.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 22 | 23 | 40 | 41 | 42 | 51 | 52 | 59 | 60 | 77 | 78 | 79 | 97 | 98 | 106 | 107 | 108 | 121 | 122 | 130 | 131 | -------------------------------------------------------------------------------- /bitframe/src/main/res/layout/view_single.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 30 | 31 | 44 | 45 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /bitframe/src/main/res/layout/view_tripple_horz.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 16 | 17 | 24 | 25 | 42 | 43 | 44 | 55 | 56 | 63 | 64 | 81 | 82 | 83 | 95 | 96 | 103 | 104 | 121 | 122 | 123 | 136 | 137 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /bitframe/src/main/res/layout/view_tripple_parr_horz.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 22 | 23 | 40 | 41 | 42 | 53 | 54 | 61 | 62 | 79 | 80 | 81 | 90 | 91 | 98 | 99 | 116 | 117 | 118 | 131 | 132 | 140 | 141 | -------------------------------------------------------------------------------- /bitframe/src/main/res/layout/view_tripple_parr_vert.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 21 | 22 | 39 | 40 | 41 | 49 | 50 | 57 | 58 | 75 | 76 | 77 | 84 | 85 | 92 | 93 | 110 | 111 | 112 | 125 | 126 | 134 | 135 | -------------------------------------------------------------------------------- /bitframe/src/main/res/layout/view_tripple_vert.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 14 | 15 | 22 | 23 | 40 | 41 | 42 | 53 | 54 | 61 | 62 | 79 | 80 | 81 | 94 | 95 | 102 | 103 | 120 | 121 | 122 | 135 | 136 | 144 | 145 | -------------------------------------------------------------------------------- /bitframe/src/main/res/values-hdpi/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0dp 4 | 144dp 5 | 24dp 6 | 36dp 7 | 48dp 8 | 5.25dp 9 | 7.5dp 10 | 3.75dp 11 | 2.25dp 12 | 4.5dp 13 | 22.55dp 14 | 26.32dp 15 | 10.5dp 16 | 15dp 17 | 37.5dp 18 | 30dp 19 | 135dp 20 | 41.25dp 21 | 22 | 23 | 1.13dp 24 | 25 | 26 | 27 | -37.5dp 28 | 29 | 30 | 20.25sp 31 | 22.5sp 32 | 18.75sp 33 | 15sp 34 | 36sp 35 | -------------------------------------------------------------------------------- /bitframe/src/main/res/values-xhdpi/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0dp 4 | 192dp 5 | 6 | 32dp 7 | 48dp 8 | 64dp 9 | 10 | 11 | 12 | 7dp 13 | 10dp 14 | 5dp 15 | 3dp 16 | 6dp 17 | 30dp 18 | 35dp 19 | 14dp 20 | 20dp 21 | 50dp 22 | 40dp 23 | 180dp 24 | 55dp 25 | 26 | 27 | 1.5dp 28 | 29 | 30 | -50dp 31 | 32 | 33 | 27sp 34 | 30sp 35 | 25sp 36 | 20sp 37 | 48sp 38 | 39 | 40 | -------------------------------------------------------------------------------- /bitframe/src/main/res/values-xxhdpi/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 0dp 4 | 268.8dp 5 | 44.8dp 6 | 67.2dp 7 | 89.6dp 8 | 9.8dp 9 | 14dp 10 | 7dp 11 | 4.2dp 12 | 8.4dp 13 | 42dp 14 | 49dp 15 | 19.6dp 16 | 28dp 17 | 70dp 18 | 56dp 19 | 252dp 20 | 77dp 21 | 22 | 23 | 2.1dp 24 | 25 | 26 | -70dp 27 | 28 | 29 | 30 | 37.8sp 31 | 42sp 32 | 35sp 33 | 28sp 34 | 67.2sp 35 | -------------------------------------------------------------------------------- /bitframe/src/main/res/values/attributes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | false 6 | 7 | 70 8 | 0 9 | 4 10 | 99 11 | 25% 12 | 13 | @integer/trans_percent 14 | @integer/diff_threshold 15 | @integer/max_frame 16 | @integer/max_extra 17 | @fraction/min_add_rato 18 | @drawable/ic_launcher 19 | @drawable/ic_launcher 20 | @dimen/d_64 21 | @dimen/d_64 22 | @dimen/d_192 23 | @dimen/d_192 24 | @bool/bool_false 25 | @bool/bool_false 26 | @bool/bool_true 27 | @bool/bool_true 28 | @bool/bool_false 29 | @bool/bool_false 30 | @bool/bool_false 31 | @bool/bool_true 32 | @bool/bool_true 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /bitframe/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #33000000 7 | #ff6b20ae 8 | #66ffffff 9 | #42000000 10 | #ffffff 11 | #e5e5e5 12 | #4d4d4d 13 | #66000000 14 | #66000000 15 | 16 | -------------------------------------------------------------------------------- /bitframe/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 160dp 5 | 6 | 16dp 7 | 16dp 8 | 16dp 9 | 10 | 0dp 11 | 12 | 13 | 14 | 106.66dp 15 | 17.77dp 16 | 26.66dp 17 | 35.55dp 18 | 3.88dp 19 | 5.55dp 20 | 2.77dp 21 | 1.66dp 22 | 3.33dp 23 | 16.66dp 24 | 19.44dp 25 | 7.77dp 26 | 11.11dp 27 | 27.77dp 28 | 22.22dp 29 | 100dp 30 | 30.55dp 31 | 32 | 33 | 0.84dp 34 | 35 | 36 | -27.77dp 37 | 38 | 39 | 15sp 40 | 16.66sp 41 | 13.88sp 42 | 11.11sp 43 | 26.66sp 44 | 45 | -------------------------------------------------------------------------------- /bitframe/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /bitframe/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BitFrame 3 | 4 | -------------------------------------------------------------------------------- /bitframe/src/test/java/proj/me/bitframe/Dimension.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | /** 4 | * Created by root on 29/9/16. 5 | */ 6 | 7 | public class Dimension { 8 | public int widthPixels; 9 | public int heightPixels; 10 | 11 | public Dimension(int widthPixels, int heightPixels){ 12 | this.widthPixels = widthPixels; 13 | this.heightPixels = heightPixels; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /bitframe/src/test/java/proj/me/bitframe/DimensionsModel.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | /** 4 | * Created by root on 29/9/16. 5 | */ 6 | 7 | public class DimensionsModel { 8 | 9 | public static Dimension[] DIMENSIONS = { 10 | new Dimension(1080, 1920), 11 | new Dimension(1440, 2560), 12 | new Dimension(1200, 1920), 13 | new Dimension(768, 1280), 14 | new Dimension(800, 1280), 15 | new Dimension(720, 1280), 16 | new Dimension(480, 800), 17 | new Dimension(240, 320), 18 | new Dimension(240, 400), 19 | new Dimension(240, 432), 20 | new Dimension(480, 854), 21 | new Dimension(320, 480), 22 | 23 | //inverse dimensions, for tablets 24 | new Dimension(2560, 1800), 25 | new Dimension(2048, 1536), 26 | new Dimension(2560, 1600), 27 | new Dimension(1280, 800), 28 | new Dimension(1280, 720), 29 | new Dimension(1024, 600) 30 | }; 31 | 32 | 33 | public boolean vertLayout; 34 | public boolean firstImageLeftOrTop; 35 | public int[] params; 36 | public int widthPixels; 37 | public int heightPixels; 38 | public DimensionsModel(int[] params, boolean firstImageLeftOrTop, boolean vertLayout, int widthPixels, int heightPixels){ 39 | this.vertLayout = vertLayout; 40 | this.firstImageLeftOrTop = firstImageLeftOrTop; 41 | this.params = params; 42 | this.widthPixels = widthPixels; 43 | this.heightPixels = heightPixels; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /bitframe/src/test/java/proj/me/bitframe/MultiDimensionModel.java: -------------------------------------------------------------------------------- 1 | package proj.me.bitframe; 2 | 3 | import proj.me.bitframe.dimentions.ImageOrder; 4 | import proj.me.bitframe.dimentions.LayoutType; 5 | 6 | /** 7 | * Created by root on 29/9/16. 8 | */ 9 | 10 | public class MultiDimensionModel { 11 | public ImageOrder[] imageOrders; 12 | public LayoutType layoutType; 13 | public int[] params; 14 | public int widthPixels; 15 | public int heightPixels; 16 | public MultiDimensionModel(int[] params, ImageOrder[] imageOrders, LayoutType layoutType, int widthPixels, int heightPixels){ 17 | this.layoutType = layoutType; 18 | this.imageOrders = imageOrders; 19 | this.params = params; 20 | this.widthPixels = widthPixels; 21 | this.heightPixels = heightPixels; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | maven { 7 | url 'https://maven.google.com/' 8 | name 'Google' 9 | } 10 | } 11 | dependencies { 12 | classpath 'com.android.tools.build:gradle:4.0.2' 13 | 14 | // NOTE: Do not place your application dependencies here; they belong 15 | // in the individual module build.gradle files 16 | } 17 | } 18 | 19 | allprojects { 20 | repositories { 21 | jcenter() 22 | maven { 23 | url 'https://maven.google.com/' 24 | name 'Google' 25 | } 26 | } 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | android.enableJetifier=true 20 | android.useAndroidX=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deepaktwr/BitFrames/2aa5a112eba49c4d9b6be50cb992df61816f8c62/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Dec 24 12:05:08 IST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':bitframe' 2 | --------------------------------------------------------------------------------