Compare commits

...

6 Commits
yuying ... main

@ -1 +1,3 @@
# Android_Colorize
# Update Jenkins 2022/4/1

@ -12,7 +12,7 @@ android {
applicationId 'com.echo.colorize'
minSdk 21
targetSdk 30
versionCode 1
versionCode 5
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -25,6 +25,7 @@ android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
versionNameSuffix '2'
}
}
compileOptions {
@ -92,5 +93,7 @@ dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'
implementation("com.android.billingclient:billing:4.0.0")
}

@ -0,0 +1,39 @@
{
"project_info": {
"project_number": "675677589197",
"project_id": "android-colorize",
"storage_bucket": "android-colorize.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:675677589197:android:6a326992f3f1a26ad3e384",
"android_client_info": {
"package_name": "com.echo.colorize"
}
},
"oauth_client": [
{
"client_id": "675677589197-h68j30ga4sgb7q7ml4838vgs47gic5dg.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBP2PgEHuz8TLE0LikRV5I19piagGG4CQg"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "675677589197-h68j30ga4sgb7q7ml4838vgs47gic5dg.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"versionCode": 4,
"versionName": "1.02",
"outputFile": "app-release.apk"
}
],

@ -6,9 +6,9 @@
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"></uses-permission>
<!-- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>-->
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>-->
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"></uses-permission>-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
@ -24,6 +24,7 @@
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
@ -71,6 +72,17 @@
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name="com.echo.colorizeit.ui.a_comments_details.CommentsActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/Theme.ColorizeApplication.NoActionBar">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name="com.echo.colorizeit.ui.a_camera_activity.CameraKitActivity"
android:exported="true"

@ -16,10 +16,14 @@ public class APP extends Application {
// 提供 this、App ID、App Key、Server Host 作为参数
// 注意这里千万不要调用 cn.leancloud.core.LeanCloud 的 initialize 方法,否则会出现 NetworkOnMainThread 等错误。
// LeanCloud.initialize(this,
// "IIuObRE1fWDsL8sOMXuqLgux-gzGzoHsz",
// "IwTKYR5dPLT901k7hlbGxtuX",
// "https://iiuobre1.lc-cn-n1-shared.com");
LeanCloud.initialize(this,
"IIuObRE1fWDsL8sOMXuqLgux-gzGzoHsz",
"IwTKYR5dPLT901k7hlbGxtuX",
"https://iiuobre1.lc-cn-n1-shared.com");
"aXtS1Ar4i3CRKa6oc72bp5Ro-gzGzoHsz",
"KD4f0t7AfuBKztLIC8GeATaR",
"https://axts1ar4.lc-cn-n1-shared.com");
LeanCloud.setLogLevel(LCLogger.Level.DEBUG);

@ -26,6 +26,26 @@ public class PhotoLib {
byte[] byteArray = buf.array();
return byteArray;
}
public static String saveImageTmp(Context context, Bitmap bmp) {
// 首先保存图片
File appDir = context.getFilesDir();
if (!appDir.exists()) {
appDir.mkdir();
}
String fileName = System.currentTimeMillis() + ".png";
File file = new File(appDir, fileName);
try {
FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
bmp.compress(Bitmap.CompressFormat.PNG, 80, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return file.getAbsolutePath();
}
public static Bitmap BytesToBitmap(byte[] bytes){
Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
return bitmap;

@ -28,6 +28,8 @@ import com.luck.picture.lib.widget.longimage.SubsamplingScaleImageView;
* @authorluck
* @date2019-11-13 17:02
* @describeGlide
* from Github
*
*/
public class GlideEngine implements ImageEngine {

@ -0,0 +1,14 @@
package com.echo.colorizeit.Interfaces;
import android.graphics.Bitmap;
/**
* @Author: WangYuyang
* @Date: 2021/11/10-19:38
* @Project: My Application
* @Package: com.echo.colorizeit.Interfaces
* @Description:
**/
public interface ImageRequestListener {
void success(Bitmap image);
}

@ -5,28 +5,25 @@ import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.echo.colorizeit.ui.a_login_activity.LoginViewActivity;
import com.etebarian.meowbottomnavigation.MeowBottomNavigation;
import com.echo.colorizeit.ImageUtil.PhotoLib;
import com.example.myapplication.R;
import com.echo.colorizeit.ui.a_image_upload_activity.ImageUploadViewActivity;
import com.google.android.material.snackbar.Snackbar;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import androidx.appcompat.app.AppCompatActivity;
import com.echo.colorizeit.ImageUtil.PhotoLib;
import com.echo.colorizeit.ui.a_image_upload_activity.ImageUploadViewActivity;
import com.echo.colorizeit.ui.a_login_activity.LoginViewActivity;
import com.etebarian.meowbottomnavigation.MeowBottomNavigation;
import com.example.myapplication.R;
import com.example.myapplication.databinding.ActivityMainBinding;
import com.google.android.material.snackbar.Snackbar;
import java.io.File;
import java.io.FileOutputStream;
@ -72,16 +69,19 @@ public class MainActivity extends AppCompatActivity {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
// NavigationUI.setupWithNavController(binding.navView, navController);
//MeowBottomNavigation is a third-parity view
//com.etebarian:meow-bottom-navigation:1.2.0
MeowBottomNavigation bottomNavigation = binding.navView;
bottomNavigation.add(new MeowBottomNavigation.Model(1, R.drawable.ic_home_black_24dp));
bottomNavigation.add(new MeowBottomNavigation.Model(2, R.drawable.ic_menu_gallery));
// bottomNavigation.add(new MeowBottomNavigation.Model(3, R.drawable.ic_menu_slideshow));
bottomNavigation.add(new MeowBottomNavigation.Model(3, R.drawable.ic_menu_slideshow));
bottomNavigation.add(new MeowBottomNavigation.Model(4, R.drawable.ic_baseline_person_24));
bottomNavigation.show(1, true);
bottomNavigation.setOnClickMenuListener(new Function1<MeowBottomNavigation.Model, Unit>() {
@Override
public Unit invoke(MeowBottomNavigation.Model model) {
switch (model.getId()){
switch (model.getId()) {
case 1:
navController.navigate(R.id.nav_slideshow);
break;
@ -90,9 +90,9 @@ public class MainActivity extends AppCompatActivity {
navController.navigate(R.id.nav_gallery);
break;
// case 3:
// navController.navigate(R.id.nav_home);
// break;
case 3:
navController.navigate(R.id.communityFragment2);
break;
case 4:
navController.navigate(R.id.nav_userFragment);
@ -103,8 +103,6 @@ public class MainActivity extends AppCompatActivity {
});
// DrawerLayout drawer = binding.drawerLayout;
// NavigationView navigationView = binding.navView;
// // Passing each menu ID as a set of Ids because each
@ -160,15 +158,15 @@ public class MainActivity extends AppCompatActivity {
}
}
@Override
public void onStart() {
super.onStart();
if (LCUser.currentUser() == null) {
Intent intent = new Intent(this, LoginViewActivity.class);
startActivity(intent);
}
else{
if(LCUser.currentUser().isAnonymous()){
} else {
if (LCUser.currentUser().isAnonymous()) {
Intent intent = new Intent(this, LoginViewActivity.class);
startActivity(intent);
}

@ -0,0 +1,23 @@
package com.echo.colorizeit.ui.a_add_newpost_activity;
import android.os.Bundle;
import androidx.annotation.Nullable;
import com.echo.colorizeit.ui.BaseActivity;
/**
* @Author: WangYuyang
* @Date: 2021/11/10-19:15
* @Project: My Application
* @Package: com.echo.colorizeit.ui.a_add_newpost_activity
* @Description:
**/
public class AddNewPostActivity extends BaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}

@ -0,0 +1,143 @@
package com.echo.colorizeit.ui.a_comments_details;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.myapplication.databinding.CommunityDetailItemBinding;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import cn.leancloud.LCFile;
import cn.leancloud.LCObject;
import cn.leancloud.LCQuery;
import cn.leancloud.gson.GsonObject;
import cn.leancloud.json.JSONObject;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
/**
* @Author: WangYuyang
* @Date: 2021/11/13-14:34
* @Project: My Application
* @Package: com.echo.colorizeit.ui.a_comments_details
* @Description:
**/
public class CommentItemAdapter extends RecyclerView.Adapter {
private CommentsActivity context;
private JSONObject comments = new GsonObject();
public CommentItemAdapter(CommentsActivity context) {
this.context = context;
}
public void update_comments(JSONObject posts) {
this.comments = new GsonObject(posts);
notifyDataSetChanged();
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
CommunityDetailItemBinding binding;
binding = CommunityDetailItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
CommentsViewHolder holder = new CommentsViewHolder(binding.getRoot());
holder.binding = binding;
return holder;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
CommentsViewHolder holder1 = (CommentsViewHolder) holder;
JSONObject object = comments.getJSONObject(String.valueOf(position));
holder1.binding.commentCommentText.setText(object.getString("text"));
holder1.binding.commentPostDate.setText(object.getString("time"));
holder1.binding.commentUsername.setText(object.getString("username") != null ? object.getString("username").toString() : "");
holder1.binding.commentsUserIcon.setClipToOutline(true);
JSONObject user = object.getJSONObject("User");
if (user != null) {
System.out.println(user);
JSONObject user_icon = user.getJSONObject("serverData");
user_icon = user_icon.getJSONObject("user_icon");
JSONObject user_avatar = user_icon.getJSONObject("serverData");
LCQuery<LCObject> query2 = new LCQuery<>("_File");
query2.getInBackground(user_avatar.getString("objectId")).subscribe(new Observer<LCObject>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull LCObject lcObject) {
LCFile tmp = (LCFile) lcObject;
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(400 * position);
} catch (InterruptedException e) {
e.printStackTrace();
}
URL url = null;
try {
url = new URL(tmp.getUrl());
} catch (MalformedURLException e) {
e.printStackTrace();
}
InputStream is = null;
try {
is = url.openStream();
} catch (Exception e) {
e.printStackTrace();
}
if (is != null) {
Bitmap bitmap = BitmapFactory.decodeStream(is);
context.runOnUiThread(new Runnable() {
@Override
public void run() {
holder1.binding.commentsUserIcon.setImageBitmap(bitmap);
}
});
}
}
}).start();
}
@Override
public void onError(@NonNull Throwable e) {
}
@Override
public void onComplete() {
}
});
}
}
@Override
public int getItemCount() {
return comments.size();
}
private static class CommentsViewHolder extends RecyclerView.ViewHolder {
public CommunityDetailItemBinding binding;
public CommentsViewHolder(@NonNull View itemView) {
super(itemView);
}
}
}

@ -0,0 +1,110 @@
package com.echo.colorizeit.ui.a_comments_details;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import com.echo.colorizeit.ImageUtil.PhotoLib;
import com.echo.colorizeit.ui.BaseActivity;
import com.example.myapplication.databinding.CommunityDetailBinding;
import java.time.LocalTime;
import java.util.ArrayList;
import cn.leancloud.LCObject;
import cn.leancloud.LCQuery;
import cn.leancloud.LCUser;
import cn.leancloud.gson.GsonObject;
import cn.leancloud.json.JSONObject;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
/**
* @Author: WangYuyang
* @Date: 2021/11/13-14:32
* @Project: My Application
* @Package: com.echo.colorizeit.ui.a_comments_details
* @Description:
**/
public class CommentsActivity extends BaseActivity {
private CommunityDetailBinding binding;
private CommentsViewModel model;
private CommentItemAdapter adapter = new CommentItemAdapter(this);
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = CommunityDetailBinding.inflate(getLayoutInflater());
model = new ViewModelProvider(this).get(CommentsViewModel.class);
setContentView(binding.getRoot());
Intent intent = getIntent();
String image_path = intent.getStringExtra("image_path");
String image_object_id = intent.getStringExtra("object_id");
LCQuery<LCObject> query = new LCQuery<>("Posts");
query.getInBackground(image_object_id).subscribe(new Observer<LCObject>() {
public void onSubscribe(Disposable disposable) {}
public void onNext(LCObject post) {
JSONObject comments = post.getJSONObject("comments");
adapter.update_comments(comments);
binding.sendCommentButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("sendCommentButton");
String text = binding.commentTextField.getText().toString();
JSONObject comment_object = new GsonObject();
comment_object.put("userid", LCUser.currentUser().getObjectId());
comment_object.put("username", LCUser.currentUser().getUsername());
comment_object.put("text", text);
comment_object.put("User", LCUser.currentUser());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
comment_object.put("time", LocalTime.now().toString());
}
comments.put(String.valueOf(comments.size()),comment_object);
post.put("comments",comments);
post.saveInBackground().subscribe(new Observer<LCObject>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull LCObject o) {
adapter.update_comments(comments);
System.out.println("Save finished.");
}
@Override
public void onError(@NonNull Throwable e) {
}
@Override
public void onComplete() {
}
});
}
});
}
public void onError(Throwable throwable) {}
public void onComplete() {}
});
Bitmap image = BitmapFactory.decodeFile(image_path);
binding.imageView3.setImageBitmap(image);
binding.recyclerView.setAdapter(adapter);
binding.imageView3.setClipToOutline(true);
}
}

@ -0,0 +1,13 @@
package com.echo.colorizeit.ui.a_comments_details;
import androidx.lifecycle.ViewModel;
/**
* @Author: WangYuyang
* @Date: 2021/11/13-14:32
* @Project: My Application
* @Package: com.echo.colorizeit.ui.a_comments_details
* @Description:
**/
public class CommentsViewModel extends ViewModel {
}

@ -60,8 +60,6 @@ public class LoginViewActivity extends BaseActivity {
}
binding.signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

@ -0,0 +1,138 @@
package com.echo.colorizeit.ui.f_community_view;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModelProvider;
import com.echo.colorizeit.ImageUtil.thirdparty.GlideEngine;
import com.echo.colorizeit.ui.BaseFragment;
import com.example.myapplication.databinding.FragmentCommunityBinding;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.listener.OnResultCallbackListener;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import cn.leancloud.LCFile;
import cn.leancloud.LCObject;
import cn.leancloud.LCQuery;
import cn.leancloud.LCUser;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
/**
* @Author: WangYuyang
* @Date: 2021/11/10-18:16
* @Project: My Application
* @Package: com.echo.colorizeit.ui.f_community_view
* @Description:
**/
public class CommunityFragment extends BaseFragment {
public CommunityViewModel model;
private FragmentCommunityBinding binding;
private PostAdapter adapter = new PostAdapter(this);
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = FragmentCommunityBinding.inflate(getLayoutInflater());
model = new ViewModelProvider(this).get(CommunityViewModel.class);
binding.rcGallery.setAdapter(adapter);
do_update_posts();
binding.addNewPostButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PictureSelector.create(getActivity())
.openGallery(PictureMimeType.ofAll())
.imageEngine(GlideEngine.createGlideEngine())
.selectionMode(PictureConfig.SINGLE)
.forResult(new OnResultCallbackListener<LocalMedia>() {
@Override
public void onResult(List<LocalMedia> result) {
String sourceFilePath = result.get(0).getRealPath();
// Bitmap img = BitmapFactory.decodeFile(sourceFilePath);
try {
String[] tmp = sourceFilePath.split("\\.");
LCFile file = LCFile.withAbsoluteLocalPath(System.currentTimeMillis() + tmp[tmp.length - 1], sourceFilePath);
file.saveInBackground().subscribe(new Observer<LCFile>() {
public void onSubscribe(Disposable disposable) {
}
public void onNext(LCFile file) {
System.out.println("文件保存完成。URL" + file.getUrl());
LCObject post = new LCObject("Posts");
post.put("Image", file);
post.put("Username", LCUser.currentUser().getUsername());
post.put("User", LCUser.currentUser());
post.saveInBackground().subscribe(new Observer<LCObject>() {
public void onSubscribe(Disposable disposable) {}
public void onNext(LCObject todo) {
// 成功保存之后,执行其他逻辑
System.out.println("保存成功。objectId" + todo.getObjectId());
do_update_posts();
}
public void onError(Throwable throwable) {
// 异常处理
}
public void onComplete() {}
});
}
public void onError(Throwable throwable) {
// 保存失败,可能是文件无法被读取,或者上传过程中出现问题
}
public void onComplete() {
}
});
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
@Override
public void onCancel() {
}
});
}
});
return binding.getRoot();
}
private void do_update_posts() {
LCQuery<LCObject> query = new LCQuery<>("Posts");
query = query.include("User");
query.findInBackground().subscribe(new Observer<List<LCObject>>() {
public void onSubscribe(Disposable disposable) {
}
public void onNext(List<LCObject> posts) {
ArrayList tmp = new ArrayList(posts);
adapter.update_posts(tmp);
}
public void onError(Throwable throwable) {
}
public void onComplete() {
}
});
}
}

@ -0,0 +1,20 @@
package com.echo.colorizeit.ui.f_community_view;
import androidx.lifecycle.MediatorLiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import java.util.ArrayList;
import cn.leancloud.LCObject;
/**
* @Author: WangYuyang
* @Date: 2021/11/10-18:16
* @Project: My Application
* @Package: com.echo.colorizeit.ui.f_community_view
* @Description:
**/
public class CommunityViewModel extends ViewModel {
// private ArrayList<LCObject> posts = new ArrayList<>();
}

@ -0,0 +1,326 @@
package com.echo.colorizeit.ui.f_community_view;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.provider.MediaStore;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.echo.colorizeit.ImageUtil.PhotoLib;
import com.echo.colorizeit.Util;
import com.echo.colorizeit.ui.a_comments_details.CommentsActivity;
import com.example.myapplication.databinding.CommunityItemBinding;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import cn.leancloud.LCFile;
import cn.leancloud.LCObject;
import cn.leancloud.LCQuery;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
/**
* @Author: WangYuyang
* @Date: 2021/11/10-18:16
* @Project: My Application
* @Package: com.echo.colorizeit.ui.f_community_view
* @Description:
**/
public class PostAdapter extends RecyclerView.Adapter {
private CommunityFragment context;
private ArrayList<LCObject> posts = new ArrayList<>();
public PostAdapter(CommunityFragment context) {
this.context = context;
}
public void update_posts(List<LCObject> posts) {
this.posts = new ArrayList<>(posts);
notifyDataSetChanged();
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
CommunityItemBinding binding;
binding = CommunityItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
PostViewHolder holder = new PostViewHolder(binding.getRoot());
holder.binding = binding;
return holder;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
PostViewHolder holder1 = (PostViewHolder) holder;
LCObject object = posts.get(position);
holder1.binding.postedBy.setText(object.get("Username") != null ? object.get("Username").toString() : "");
holder1.binding.thumbUpCount.setText(object.get("thumb_up_count").toString());
holder1.binding.shareCount.setText(object.get("share_count").toString());
holder1.binding.downloadCount.setText(object.get("download_count").toString());
holder1.binding.postedTime.setText(object.getCreatedAt().toLocaleString());
holder1.binding.userIcon.setClipToOutline(true);
LCObject file_id = (LCObject) object.get("Image");
LCQuery<LCObject> query = new LCQuery<>("_File");
query.getInBackground(file_id.getObjectId()).subscribe(new Observer<LCObject>() {
public void onSubscribe(Disposable disposable) {
}
public void onNext(LCObject file) {
LCFile tmp = (LCFile) file;
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(400 * position);
} catch (InterruptedException e) {
e.printStackTrace();
}
URL url = null;
try {
url = new URL(tmp.getUrl());
} catch (MalformedURLException e) {
e.printStackTrace();
}
InputStream is = null;
try {
is = url.openStream();
} catch (Exception e) {
e.printStackTrace();
}
if (is != null) {
Bitmap bitmap = BitmapFactory.decodeStream(is);
context.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
holder1.binding.rcImageView2.setImageBitmap(bitmap);
holder1.binding.rcImageView2.setVisibility(View.VISIBLE);
holder1.binding.imageLoadingViewAnim.setVisibility(View.GONE);
holder1.binding.rcImageView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(holder.itemView.getContext(), CommentsActivity.class);
String image_path = PhotoLib.saveImageTmp(holder.itemView.getContext(),bitmap);
intent.putExtra("image_path", image_path);
intent.putExtra("object_id", object.getObjectId());
holder.itemView.getContext().startActivity(intent);
}
});
holder1.binding.thumbUpButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
object.put("thumb_up_count", ((int) object.get("thumb_up_count")) + 1);
holder1.binding.thumbUpCount.setText(String.valueOf((int) object.get("thumb_up_count")));
object.saveInBackground().subscribe(new Observer<LCObject>() {
public void onSubscribe(Disposable disposable) {
}
public void onNext(LCObject savedTodo) {
System.out.println("保存成功");
}
public void onError(Throwable throwable) {
System.out.println("保存失败!");
}
public void onComplete() {
}
});
;
}
});
holder1.binding.gallerySaveButton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
object.put("download_count", ((int) object.get("download_count")) + 1);
holder1.binding.downloadCount.setText(String.valueOf(((int) object.get("download_count"))));
object.saveInBackground().subscribe(new Observer<LCObject>() {
public void onSubscribe(Disposable disposable) {
}
public void onNext(LCObject savedTodo) {
System.out.println("保存成功");
}
public void onError(Throwable throwable) {
System.out.println("保存失败!");
}
public void onComplete() {
}
});
;
Bitmap tmp = bitmap;
String data = MediaStore.Images.Media.insertImage(holder.itemView.getContext().getContentResolver(), tmp, String.valueOf(System.currentTimeMillis()), ":)");
final AlertDialog.Builder alterDialog = new AlertDialog.Builder(holder.itemView.getContext());
alterDialog.setTitle("Image saved successfully.");//文字
alterDialog.setMessage("You can view it in your gallery.");//提示消息
alterDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setType("image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
holder.itemView.getContext().startActivity(intent);
}
});
alterDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alterDialog.show();
}
});
holder1.binding.galleryShareButton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
object.put("share_count", ((int) object.get("share_count")) + 1);
holder1.binding.shareCount.setText(String.valueOf(((int) object.get("share_count"))));
object.saveInBackground().subscribe(new Observer<LCObject>() {
public void onSubscribe(Disposable disposable) {
}
public void onNext(LCObject savedTodo) {
System.out.println("保存成功");
}
public void onError(Throwable throwable) {
System.out.println("保存失败!");
}
public void onComplete() {
}
});
;
Bitmap tmp = bitmap;
String data = MediaStore.Images.Media.insertImage(holder.itemView.getContext().getContentResolver(), tmp, String.valueOf(System.currentTimeMillis()), ":)");
while (data == null) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Uri ColorizedImageUri = Uri.parse(data);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, ColorizedImageUri);
intent.putExtra(Intent.EXTRA_SUBJECT, "Share");//添加分享内容标题
intent = Intent.createChooser(intent, "Share");
holder.itemView.getContext().startActivity(intent);
}
});
}
});
}
}
}).start();
}
public void onError(Throwable throwable) {
}
public void onComplete() {
}
});
LCObject user = (LCObject) object.get("User");
System.out.println(user);
LCObject user_avatar = (LCObject) user.get("user_icon");
LCQuery<LCObject> query2 = new LCQuery<>("_File");
query2.getInBackground(user_avatar.getObjectId()).subscribe(new Observer<LCObject>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
@Override
public void onNext(@NonNull LCObject lcObject) {
LCFile tmp = (LCFile) lcObject;
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(300 * position);
} catch (InterruptedException e) {
e.printStackTrace();
}
URL url = null;
try {
url = new URL(tmp.getUrl());
} catch (MalformedURLException e) {
e.printStackTrace();
}
InputStream is = null;
try {
is = url.openStream();
} catch (Exception e) {
e.printStackTrace();
}
if (is != null) {
Bitmap bitmap = BitmapFactory.decodeStream(is);
context.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
holder1.binding.userIcon.setImageBitmap(bitmap);
}
});
}
}
}).start();
}
@Override
public void onError(@NonNull Throwable e) {
}
@Override
public void onComplete() {
}
});
}
@Override
public int getItemCount() {
return posts.size();
}
private static class PostViewHolder extends RecyclerView.ViewHolder {
public CommunityItemBinding binding;
public PostViewHolder(@NonNull View itemView) {
super(itemView);
}
}
}

@ -1,6 +1,12 @@
package com.echo.colorizeit.ui.f_gallery_view;
import static com.echo.colorizeit.Util.check_is_grayscale;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.transition.Fade;
@ -16,12 +22,22 @@ import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
import com.echo.colorizeit.ImageUtil.PhotoLib;
import com.echo.colorizeit.ImageUtil.rcImage;
import com.echo.colorizeit.ImageUtil.thirdparty.GlideEngine;
import com.echo.colorizeit.Util;
import com.echo.colorizeit.ui.BaseFragment;
import com.echo.colorizeit.ui.a_image_upload_activity.ImageUploadViewActivity;
import com.echo.colorizeit.ui.a_login_activity.LoginViewActivity;
import com.example.myapplication.R;
import com.example.myapplication.databinding.FragmentClarityEnhancementBinding;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.listener.OnResultCallbackListener;
import org.tensorflow.lite.support.image.TensorImage;
import java.io.File;
import java.util.ArrayList;
@ -66,6 +82,31 @@ public class GalleryFragment extends BaseFragment {
adapter = new ImageAdapter(getRcImageList());
// image_gallery.setLayoutManager(layoutManager);
image_gallery.setAdapter(adapter);
binding.textView4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("textGallery");
PictureSelector.create(getActivity())
.openGallery(PictureMimeType.ofAll())
.imageEngine(GlideEngine.createGlideEngine())
.selectionMode(PictureConfig.SINGLE)
.forResult(new OnResultCallbackListener<LocalMedia>() {
@Override
public void onResult(List<LocalMedia> result) {
String sourceFilePath = result.get(0).getRealPath();
Bitmap img = BitmapFactory.decodeFile(sourceFilePath);
PhotoLib.saveImageToGallery(getContext(),img);
}
@Override
public void onCancel() {
// 取消
}
});
}
});
// layoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
//防止item 交换位置
// image_gallery.addOnScrollListener(new RecyclerView.OnScrollListener() {

@ -9,14 +9,21 @@ import android.view.ViewGroup;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.BillingResult;
import com.android.billingclient.api.Purchase;
import com.android.billingclient.api.PurchasesUpdatedListener;
import com.echo.colorizeit.ui.a_login_activity.LoginViewActivity;
import com.example.myapplication.R;
import com.example.myapplication.databinding.FragmentUserBinding;
import java.util.List;
import cn.leancloud.LCObject;
import cn.leancloud.LCUser;
import io.reactivex.disposables.Disposable;
@ -25,18 +32,30 @@ import io.reactivex.disposables.Disposable;
* @author Wang Yuyang
* @date 2021-09-22 13:52:43
*/
public class UserFragment extends Fragment {
public class UserFragment extends Fragment implements PurchasesUpdatedListener {
private UserFragmentViewModel model;
private FragmentUserBinding binding;
private UserFragment _this = this;
private View root;
private PurchasesUpdatedListener purchasesUpdatedListener = new PurchasesUpdatedListener() {
@Override
public void onPurchasesUpdated(BillingResult billingResult, List<Purchase> purchases) {
// To be implemented in a later section.
}
};
private BillingClient billingClient;
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
model = new ViewModelProvider(this).get(UserFragmentViewModel.class);
binding = FragmentUserBinding.inflate(inflater, container, false);
root = binding.getRoot();
billingClient = BillingClient.newBuilder(getContext())
.setListener(purchasesUpdatedListener)
.enablePendingPurchases()
.build();
Fade slideTracition = new Fade();
slideTracition.setDuration(getResources().getInteger(R.integer.config_navAnimTime));
@ -70,6 +89,56 @@ public class UserFragment extends Fragment {
binding.TopUpBalance.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// List<String> skuList = new ArrayList<>();
// skuList.add("0");
// skuList.add("1");
// skuList.add("2");
// skuList.add("3");
// SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
// params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP);
// billingClient.startConnection(new BillingClientStateListener() {
// @Override
// public void onBillingSetupFinished(BillingResult billingResult) {
// if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
// // The BillingClient is ready. You can query purchases here.
// System.out.println("The BillingClient is ready. You can query purchases here.");
// billingClient.querySkuDetailsAsync(params.build(),
// new SkuDetailsResponseListener() {
// @Override
// public void onSkuDetailsResponse(BillingResult billingResult,
// List<SkuDetails> skuDetailsList) {
// // Process the result.
// System.out.println(billingResult.getDebugMessage());
// System.out.println(skuDetailsList);
// }
// });
// }
// }
//
// @Override
// public void onBillingServiceDisconnected() {
// // Try to restart the connection on the next request to
// // Google Play by calling the startConnection() method.
// System.out.println("Disconnected");
// }
// });
// Handle the result.
// SkuDetails object obtained above.
// SkuDetails skuDetails = ...;
//
// BillingFlowParams purchaseParams =
// BillingFlowParams.newBuilder()
// .setSkuDetails(skuDetails)
// .build();
//
// BillingClient mBillingClient;
// mBillingClient.launchBillingFlow(mActivity, purchaseParams);
// Purchase is handled in onPurchasesUpdated illustrated in the previous section.
LCUser currentUser = LCUser.getCurrentUser();
currentUser.put("Balance", model.getBalance().getValue() + 5);
currentUser.saveInBackground().subscribe(new io.reactivex.Observer<LCObject>() {
@ -205,6 +274,11 @@ public class UserFragment extends Fragment {
return root;
}
@Override
public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List<Purchase> list) {
// Logic from onActivityResult should be moved here.
}
@Override
public void onStart() {
super.onStart();

@ -0,0 +1,5 @@
<vector android:alpha="0.8" android:height="24dp"
android:tint="?attr/colorControlNormal" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM17,13l-5,5 -5,-5h3V9h4v4h3z"/>
</vector>

@ -0,0 +1,5 @@
<vector android:alpha="0.8" android:height="24dp"
android:tint="?attr/colorControlNormal" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M1,21h4L5,9L1,9v12zM23,10c0,-1.1 -0.9,-2 -2,-2h-6.31l0.95,-4.57 0.03,-0.32c0,-0.41 -0.17,-0.79 -0.44,-1.06L14.17,1 7.59,7.59C7.22,7.95 7,8.45 7,9v10c0,1.1 0.9,2 2,2h9c0.83,0 1.54,-0.5 1.84,-1.22l3.02,-7.05c0.09,-0.23 0.14,-0.47 0.14,-0.73v-2z"/>
</vector>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
</shape>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:fontFamily="@font/aclonica"
android:text="Add a new post"
android:textSize="34sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:background="@drawable/round"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView3"
tools:itemCount="2"
tools:listitem="@layout/community_detail_item" />
<EditText
android:id="@+id/comment_text_field"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="32dp"
android:ems="10"
android:hint="Give a comment here ~"
android:inputType="textPersonName"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/send_comment_button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/recyclerView" />
<Button
android:id="@+id/send_comment_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="send"
app:layout_constraintBottom_toBottomOf="@+id/comment_text_field"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/comment_text_field" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/comments_user_icon"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="@drawable/round"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
<TextView
android:id="@+id/comment_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="w1109790800@gmail.com"
app:layout_constraintStart_toEndOf="@+id/comments_user_icon"
app:layout_constraintTop_toTopOf="@+id/comments_user_icon" />
<TextView
android:id="@+id/comment_post_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:text="2021-01-21"
app:layout_constraintBottom_toBottomOf="@+id/comments_user_icon"
app:layout_constraintStart_toStartOf="@+id/comment_username"
app:layout_constraintTop_toBottomOf="@+id/comment_username" />
<TextView
android:id="@+id/comment_comment_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:text="dfdddddddddddddddddddddddddddd"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/comments_user_icon"
app:layout_constraintTop_toBottomOf="@+id/comments_user_icon" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:background="@drawable/gallery_background">
<TextView
android:id="@+id/posted_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2021-9-21"
android:textSize="10sp"
app:layout_constraintStart_toStartOf="@+id/posted_by"
app:layout_constraintTop_toBottomOf="@+id/posted_by" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/image_loading_view_anim"
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="10dp"
android:scaleType="fitXY"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="@+id/rc_image_view2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/rc_image_view2"
app:layout_constraintTop_toTopOf="parent"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/image_loading2" />
<ImageView
android:id="@+id/rc_image_view2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:padding="10dp"
android:scaleType="fitXY"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/original" />
<TextView
android:id="@+id/posted_by"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="w1109790800@gamil.com"
android:textSize="10sp"
app:layout_constraintStart_toEndOf="@+id/user_icon"
app:layout_constraintTop_toBottomOf="@+id/rc_image_view2" />
<ImageView
android:id="@+id/gallery_save_button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="@+id/gallery_share_button2"
app:layout_constraintEnd_toStartOf="@+id/gallery_share_button2"
app:layout_constraintTop_toTopOf="@+id/gallery_share_button2"
app:srcCompat="@drawable/ic_baseline_save_alt_24" />
<ImageView
android:id="@+id/gallery_share_button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginBottom="8dp"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/posted_time"
app:srcCompat="@drawable/ic_baseline_share_24" />
<ImageView
android:id="@+id/thumb_up_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="@+id/gallery_save_button2"
app:layout_constraintEnd_toStartOf="@+id/gallery_save_button2"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/gallery_save_button2"
app:srcCompat="@drawable/ic_baseline_thumb_up_24" />
<TextView
android:id="@+id/thumb_up_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="10"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/thumb_up_button"
app:layout_constraintStart_toStartOf="@+id/thumb_up_button"
app:layout_constraintTop_toBottomOf="@+id/thumb_up_button" />
<TextView
android:id="@+id/download_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="300"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/gallery_save_button2"
app:layout_constraintStart_toStartOf="@+id/gallery_save_button2"
app:layout_constraintTop_toBottomOf="@+id/gallery_save_button2" />
<TextView
android:id="@+id/share_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="100"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/gallery_share_button2"
app:layout_constraintStart_toStartOf="@+id/gallery_share_button2"
app:layout_constraintTop_toBottomOf="@+id/gallery_share_button2" />
<ImageView
android:id="@+id/user_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginStart="8dp"
android:background="@drawable/round"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="@+id/posted_time"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/posted_by"
tools:srcCompat="@tools:sample/avatars" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -38,6 +38,7 @@
android:id="@+id/rcGallery"
android:layout_width="0dp"
android:layout_height="0dp"
android:paddingBottom="45dp"
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:fontFamily="@font/aclonica"
android:text="Community"
android:textSize="34sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rcGallery"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:paddingBottom="45dp"
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView9"
app:spanCount="2"
tools:ignore="SpeakableTextPresentCheck"
tools:listitem="@layout/community_item" />
<ImageView
android:id="@+id/add_new_post_button"
android:layout_width="50dp"
android:layout_height="50dp"
app:layout_constraintBottom_toBottomOf="@+id/textView9"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView9"
app:layout_constraintTop_toTopOf="@+id/textView9"
app:srcCompat="@android:drawable/ic_menu_add" />
</androidx.constraintlayout.widget.ConstraintLayout>

@ -183,6 +183,7 @@
android:text="Remaining +5 (5$)"
android:textAllCaps="false"
android:textColor="#fff"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@+id/addRemaining10Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
@ -196,6 +197,7 @@
android:text="Remaining +10 (10$)"
android:textAllCaps="false"
android:textColor="#fff"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/AddRemaining5Button"
app:layout_constraintStart_toStartOf="@+id/AddRemaining5Button"
@ -211,6 +213,7 @@
android:text="TopUpBalance"
android:textAllCaps="false"
android:textColor="#fff"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="@+id/addRemaining10Button"
app:layout_constraintStart_toStartOf="@+id/addRemaining10Button"
app:layout_constraintTop_toBottomOf="@+id/addRemaining10Button" />

@ -26,4 +26,8 @@
android:id="@+id/nav_userFragment"
android:name="com.echo.colorizeit.ui.f_user_view.UserFragment"
android:label="UserFragment" />
<fragment
android:id="@+id/communityFragment2"
android:name="com.echo.colorizeit.ui.f_community_view.CommunityFragment"
android:label="CommunityFragment" />
</navigation>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,6 +1,11 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven{ url 'https://maven.aliyun.com/repository/central' }
maven{ url 'https://maven.aliyun.com/repository/public' }
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
google()
mavenCentral()
maven { url "https://jitpack.io" }

@ -0,0 +1,25 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven{ url 'https://maven.aliyun.com/repository/central' }
maven{ url 'https://maven.aliyun.com/repository/public' }
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
google()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "https://www.jitpack.io" }
maven { url "https://jcenter.bintray.com" }
maven { url 'https://artifactory.mxtracks.info/artifactory/gradle-dev-local/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

@ -4,9 +4,9 @@
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"></uses-permission>
<!-- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>-->
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>-->
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"></uses-permission>-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>

@ -5,6 +5,8 @@ import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.echo.photo_editor.databinding.ActivityMainBinding;
import com.echo.photo_editor.photo_editor_view.PhotoEditorView;
@ -30,6 +32,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityMainBinding.inflate(getLayoutInflater());
makeFullScreen();
//-----------------------------TEST Image-------------------------------
// sourceFilePath = "/storage/emulated/0/Pictures/Colorized Image (26).jpg";
// Intent intent = new Intent(_this, PhotoEditorView.class);
@ -64,4 +67,9 @@ public class MainActivity extends AppCompatActivity {
}
public void makeFullScreen() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}

@ -5,6 +5,8 @@ import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;
import androidx.annotation.NonNull;
@ -56,6 +58,7 @@ public class PhotoEditorView extends AppCompatActivity {
model = new ViewModelProvider(this).get(PhotoEditorViewModel.class);
baiduImageAPI = new BaiduImageAPI(this);
Intent intent = getIntent();
makeFullScreen();
String sourceFilePath = intent.getStringExtra("sourceFilePath");
model.set_sourceFilePath(sourceFilePath);
// model.getSourceFilePath().observe(this, new Observer<String>() {
@ -323,4 +326,8 @@ public class PhotoEditorView extends AppCompatActivity {
});
}
public void makeFullScreen() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}

@ -10,13 +10,12 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toTopOf="@+id/undo_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/photo_editor_text2"
tools:srcCompat="@tools:sample/avatars" />
<androidx.recyclerview.widget.RecyclerView
@ -44,6 +43,18 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/photo_editor_text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:fontFamily="cursive"
android:text="Photo Editor"
android:textSize="34sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/exit_button"
android:layout_width="40dp"

@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.echo.stinger_game">
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"

@ -13,6 +13,8 @@ import androidx.appcompat.app.AppCompatActivity;
* @date 2021-10-11 10:40:25
*/
public class GameActivity extends AppCompatActivity {
private long last_time = 0;
private int counter = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -28,9 +30,24 @@ public class GameActivity extends AppCompatActivity {
// Scene.player.startMoveUpY(6400);
// }
// });
gameView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
long delta = event.getDownTime() - last_time;
if (delta < 200) {
counter += 1;
if (counter > 20) {
counter -= 20;
}
}
System.out.println(delta);
if (counter >= 10) {
GameView.DEBUG = true;
} else {
GameView.DEBUG = false;
}
last_time = event.getDownTime();
Scene.player.startMoveUpY(6400);
return false;
}

@ -23,7 +23,7 @@ import java.util.ConcurrentModificationException;
* @date 2021-10-11 11:26:47
*/
public class GameView extends SurfaceView implements SurfaceHolder.Callback, Runnable {
public static final Boolean DEBUG = true;
public static Boolean DEBUG = false;
public static int FPS = 60;
public static int minDrawTime = 1000 / FPS;
public static Context context;
@ -151,6 +151,7 @@ public class GameView extends SurfaceView implements SurfaceHolder.Callback, Run
} catch (ConcurrentModificationException e) {
System.out.println("ConcurrentModificationException");
}
if (DEBUG) {
canvas.drawText("DrawTime: " + (end - start) + " ms", 50, 100, string_paint);
canvas.drawText("Width: " + canvas.getWidth(), 50, 150, string_paint);

Loading…
Cancel
Save