108 lines
3.3 KiB
Java
108 lines
3.3 KiB
Java
|
package app.fedilab.android.fragments;
|
||
|
/* Copyright 2019 Thomas Schneider
|
||
|
*
|
||
|
* This file is a part of Fedilab
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||
|
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||
|
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||
|
* Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||
|
* see <http://www.gnu.org/licenses>. */
|
||
|
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.graphics.Bitmap;
|
||
|
import android.graphics.Canvas;
|
||
|
import android.os.Bundle;
|
||
|
import android.view.LayoutInflater;
|
||
|
import android.view.View;
|
||
|
import android.view.ViewGroup;
|
||
|
|
||
|
import androidx.annotation.Nullable;
|
||
|
import androidx.fragment.app.Fragment;
|
||
|
|
||
|
import org.jetbrains.annotations.NotNull;
|
||
|
|
||
|
import java.util.Objects;
|
||
|
|
||
|
import app.fedilab.android.R;
|
||
|
import yalantis.com.sidemenu.interfaces.ScreenShotable;
|
||
|
|
||
|
public class ContentSettingsFragment extends Fragment implements ScreenShotable {
|
||
|
|
||
|
|
||
|
private View containerView;
|
||
|
protected int res;
|
||
|
private Bitmap bitmap;
|
||
|
|
||
|
private Context context;
|
||
|
public static final String CLOSE = "Close";
|
||
|
|
||
|
public static ContentSettingsFragment newInstance(int resId) {
|
||
|
ContentSettingsFragment contentFragment = new ContentSettingsFragment();
|
||
|
Bundle bundle = new Bundle();
|
||
|
bundle.putInt(Integer.class.getName(), resId);
|
||
|
contentFragment.setArguments(bundle);
|
||
|
return contentFragment;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onViewCreated(@NotNull View view, @Nullable Bundle savedInstanceState) {
|
||
|
super.onViewCreated(view, savedInstanceState);
|
||
|
context = getContext();
|
||
|
assert context != null;
|
||
|
this.containerView = view.findViewById(R.id.container);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onCreate(Bundle savedInstanceState) {
|
||
|
super.onCreate(savedInstanceState);
|
||
|
assert getArguments() != null;
|
||
|
res = getArguments().getInt(Integer.class.getName());
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container,
|
||
|
Bundle savedInstanceState) {
|
||
|
View rootView = inflater.inflate(R.layout.fragment_settings_reveal, container, false);
|
||
|
|
||
|
if( res == R.drawable.ic_timeline_menu_s){
|
||
|
|
||
|
}
|
||
|
|
||
|
return rootView;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onAttach(Context context) {
|
||
|
super.onAttach(context);
|
||
|
this.context = context;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void takeScreenShot() {
|
||
|
Thread thread = new Thread() {
|
||
|
@Override
|
||
|
public void run() {
|
||
|
Bitmap bitmap = Bitmap.createBitmap(containerView.getWidth(),
|
||
|
containerView.getHeight(), Bitmap.Config.ARGB_8888);
|
||
|
Canvas canvas = new Canvas(bitmap);
|
||
|
containerView.draw(canvas);
|
||
|
ContentSettingsFragment.this.bitmap = bitmap;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
thread.start();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public Bitmap getBitmap() {
|
||
|
return bitmap;
|
||
|
}
|
||
|
}
|