正在查看: Mantra Counter v25.01 应用的 Graph.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Mantra Counter v25.01 应用的 Graph.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.sweetedge.mantracounter;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Switch;
import android.widget.TextView;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.google.firebase.crashlytics.buildtools.reloc.org.apache.commons.cli.HelpFormatter;
import java.util.ArrayList;
import lecho.lib.hellocharts.model.Axis;
import lecho.lib.hellocharts.model.AxisValue;
import lecho.lib.hellocharts.model.Line;
import lecho.lib.hellocharts.model.LineChartData;
import lecho.lib.hellocharts.model.PointValue;
import lecho.lib.hellocharts.view.LineChartView;
import save_data.PDFClass;
import sweetedge.decoration.PSetTypeface;
import sweetedge.extra.PLog;
import sweetedge.popup.PToast;
import sweetedge.preference.PSharedPreference;
import sweetedge.statusbar.PStatusBar;
public class Graph extends AppCompatActivity {
LinearLayout Graph_bg;
ImageView SettingIcon;
LineChartView chart1;
LineChartView chart2;
ListView listview;
ImageView savePdf;
GraphPojo[] tenpj;
ArrayList<String> arrayList1 = new ArrayList<>();
ArrayList<String> arrayList2 = new ArrayList<>();
ArrayList<GraphPojo> listviewArrayList = new ArrayList<>();
ActivityResultLauncher<String> someActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), new ActivityResultCallback<Boolean>() {
public void onActivityResult(Boolean bool) {
if (bool.booleanValue()) {
PLog.print("Got it");
}
}
});
public static String getMonthName(int i) {
switch (i) {
case 1:
return "Jan";
case 2:
return "Feb";
case 3:
return "Mar";
case 4:
return "Apr";
case 5:
return "May";
case 6:
return "Jun";
case 7:
return "Jul";
case 8:
return "Aug";
case 9:
return "Sep";
case 10:
return "Oct";
case 11:
return "Nov";
case 12:
return "Dec";
default:
return "";
}
}
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (i == 4) {
LoadAdClass1.showIAd(this);
}
return super.onKeyDown(i, keyEvent);
}
public boolean checkPermission() {
if (Build.VERSION.SDK_INT >= 33) {
if (ContextCompat.checkSelfPermission(this, "android.permission.READ_MEDIA_IMAGES") == 0) {
if (ContextCompat.checkSelfPermission(this, "android.permission.POST_NOTIFICATIONS") == 0) {
return true;
}
this.someActivityResultLauncher.launch("android.permission.POST_NOTIFICATIONS");
return true;
}
this.someActivityResultLauncher.launch("android.permission.READ_MEDIA_IMAGES");
return false;
}
PLog.print("Comes Here");
if (ContextCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
return true;
}
if (ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.WRITE_EXTERNAL_STORAGE")) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true);
builder.setTitle("Allow Permission");
builder.setMessage("Allow Permission to move further");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
ActivityCompat.requestPermissions(Graph.this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 101);
}
});
builder.create().show();
} else {
ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 101);
}
return false;
}
public static void requestPermission(Activity activity) {
ActivityCompat.requestPermissions(activity, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"}, 1);
}
public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
super.onRequestPermissionsResult(i, strArr, iArr);
if (i == 1) {
if (iArr.length <= 0 || iArr[0] != 0) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getResources().getString(R.string.permission_msg));
builder.setPositiveButton(getResources().getString(R.string.Yes), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
Intent intent = new Intent();
intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
intent.setData(Uri.fromParts("package", Graph.this.getPackageName(), null));
Graph.this.startActivity(intent);
}
});
builder.setNegativeButton(getResources().getString(R.string.No), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
}
});
builder.create();
builder.show();
}
}
}
public void onDestroy() {
super.onDestroy();
}
private void updateTextView() {
PLog.print("Updating with 7");
PSharedPreference.setInteger(this, "DBROWS", 7);
}
protected void onResume() {
super.onResume();
updateTextView();
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
PStatusBar.changeColor(getWindow(), ContextCompat.getColor(this, R.color.orangeFontColor));
MainActivity.setLanguage(this);
setContentView(R.layout.activity_graph);
MainActivity.setLanguage(this);
this.Graph_bg = (LinearLayout) findViewById(R.id.graph_bg);
this.chart1 = findViewById(R.id.linechart);
this.chart2 = findViewById(R.id.dailylinechart);
this.listview = (ListView) findViewById(R.id.listviewofGraph);
this.savePdf = (ImageView) findViewById(R.id.savePdf);
this.SettingIcon = (ImageView) findViewById(R.id.setting_icon);
int i = 1;
if (!PSharedPreference.getBoolean(this, "C1_V", true)) {
this.chart1.setVisibility(8);
} else {
this.chart1.setVisibility(0);
}
if (!PSharedPreference.getBoolean(this, "C2_V", true)) {
this.chart2.setVisibility(8);
} else {
this.chart2.setVisibility(0);
}
this.SettingIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
?? r1 = Graph.this;
r1.ShowSetting_DialogScreen(r1);
}
});
this.savePdf.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Bitmap createBitmap;
if (Graph.this.checkPermission()) {
Bitmap bitmap = null;
if (Graph.this.chart1.getVisibility() == 8) {
Graph.this.chart1.setVisibility(0);
Graph.this.chart1.setDrawingCacheEnabled(true);
Graph.this.chart1.buildDrawingCache();
Graph.this.chart1.setVisibility(8);
createBitmap = null;
} else {
Graph.this.chart1.setDrawingCacheEnabled(true);
Graph.this.chart1.buildDrawingCache();
createBitmap = Bitmap.createBitmap(Graph.this.chart1.getDrawingCache());
}
if (Graph.this.chart2.getVisibility() == 8) {
Graph.this.chart2.setVisibility(0);
Graph.this.chart2.setDrawingCacheEnabled(true);
Graph.this.chart2.buildDrawingCache();
Graph.this.chart2.setVisibility(8);
} else {
Graph.this.chart2.setDrawingCacheEnabled(true);
Graph.this.chart2.buildDrawingCache();
bitmap = Bitmap.createBitmap(Graph.this.chart2.getDrawingCache());
}
?? r0 = Graph.this;
PDFClass.Generate((Context) r0, createBitmap, bitmap, r0.listviewArrayList, Graph.this.savePdf);
return;
}
Graph.requestPermission(Graph.this);
}
});
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
this.arrayList1.add("0");
this.arrayList2.add("0");
Database database = new Database(this);
database.open();
Cursor all = database.getAll();
if (all != null && all.moveToFirst()) {
GraphPojo[] graphPojoArr = new GraphPojo[all.getCount() + 1];
this.tenpj = graphPojoArr;
graphPojoArr[0] = new GraphPojo();
this.tenpj[0].counts = getResources().getString(R.string.total);
this.tenpj[0].dailycounts = getResources().getString(R.string.app_name);
this.tenpj[0].date = getResources().getString(R.string.dt);
this.listviewArrayList.add(this.tenpj[0]);
int i2 = 1;
while (true) {
PLog.print("Database = " + all.getString(0) + " - " + all.getString(i));
String string = all.getString(0);
int parseInt = Integer.parseInt(string.substring(string.indexOf(HelpFormatter.DEFAULT_OPT_PREFIX) + i));
this.tenpj[i2] = new GraphPojo();
this.tenpj[i2].counts = all.getString(i);
if (i2 > i) {
this.tenpj[i2].dailycounts = "" + (Long.parseLong(this.tenpj[i2].counts) - Long.parseLong(this.tenpj[i2 - 1].counts));
this.arrayList2.add(all.getString(0));
arrayList2.add(new PointValue((float) i2, (float) Long.parseLong(this.tenpj[i2].dailycounts)));
} else if (i2 == i) {
GraphPojo graphPojo = this.tenpj[i2];
graphPojo.dailycounts = graphPojo.counts;
this.arrayList2.add(all.getString(0));
}
this.tenpj[i2].date = string.substring(0, string.indexOf(HelpFormatter.DEFAULT_OPT_PREFIX)) + " - " + getMonthName(parseInt);
this.arrayList1.add(all.getString(0));
arrayList.add(new PointValue((float) i2, (float) Long.parseLong(all.getString(1))));
this.listviewArrayList.add(this.tenpj[i2]);
i2++;
if (!all.moveToNext()) {
break;
} else {
i = 1;
}
}
}
database.close();
all.close();
Line cubic = new Line(arrayList2).setColor(Color.parseColor("#dd4b48")).setCubic(false);
Line cubic2 = new Line(arrayList).setColor(Color.parseColor("#00b4ff")).setCubic(false);
ArrayList arrayList3 = new ArrayList();
arrayList3.add(cubic);
cubic.setFilled(true);
cubic.setHasLabels(true);
ArrayList arrayList4 = new ArrayList();
arrayList4.add(cubic2);
cubic2.setFilled(true);
cubic2.setHasLabels(true);
ArrayList arrayList5 = new ArrayList();
ArrayList arrayList6 = new ArrayList();
float f = 1.0f;
for (int i3 = 1; i3 < this.arrayList1.size(); i3++) {
arrayList5.add(new AxisValue(f).setLabel(this.arrayList1.get(i3)));
f += 1.0f;
}
float f2 = 1.0f;
for (int i4 = 1; i4 < this.arrayList2.size(); i4++) {
arrayList6.add(new AxisValue(f2).setLabel(this.arrayList2.get(i4)));
f2 += 1.0f;
}
Axis axis = new Axis(arrayList6);
Axis hasLines = new Axis().setHasLines(true);
axis.setName(getResources().getString(R.string.dt));
hasLines.setName(getResources().getString(R.string.app_name));
axis.setTextColor(Color.parseColor("#616196"));
axis.setTextSize(14);
hasLines.setTextColor(Color.parseColor("#dd4b48"));
hasLines.setTextSize(12);
axis.setInside(false);
axis.setHasTiltedLabels(true);
LineChartData lineChartData = new LineChartData();
lineChartData.setLines(arrayList3);
lineChartData.setAxisXBottom(axis);
lineChartData.setAxisYLeft(hasLines);
lineChartData.setBaseValue(-2.14748365E9f);
this.chart1.setLineChartData(lineChartData);
Axis axis2 = new Axis(arrayList5);
Axis hasLines2 = new Axis().setHasLines(true);
axis2.setName(getResources().getString(R.string.dt));
hasLines2.setName(getResources().getString(R.string.total));
axis2.setTextColor(Color.parseColor("#616196"));
axis2.setTextSize(14);
hasLines2.setTextColor(Color.parseColor("#00b4ff"));
hasLines2.setTextSize(14);
axis2.setInside(false);
axis2.setHasTiltedLabels(true);
LineChartData lineChartData2 = new LineChartData();
lineChartData2.setLines(arrayList4);
lineChartData2.setAxisXBottom(axis2);
lineChartData2.setAxisYLeft(hasLines2);
lineChartData2.setBaseValue(-2.14748365E9f);
this.chart2.setLineChartData(lineChartData2);
this.listview.setAdapter((ListAdapter) new GraphAdapter(this.listviewArrayList, this));
this.listview.setSelector(android.R.color.darker_gray);
}
class C1CustomDialogClass extends Dialog implements View.OnClickListener {
public final Activity c;
Switch chart1Visi;
Switch chart2Visi;
public TextView close;
public Dialog d;
Button resetAllGraphData;
Switch resetDailySwitch;
@Override
public void onClick(View view) {
}
public C1CustomDialogClass(Activity activity) {
super(activity);
this.c = activity;
}
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
requestWindowFeature(1);
setContentView(R.layout.graph_settings);
this.close = (TextView) findViewById(R.id.close_graph_settings);
this.resetDailySwitch = (Switch) findViewById(R.id.reset_to_reset);
this.chart1Visi = (Switch) findViewById(R.id.chart1_switch);
this.chart2Visi = (Switch) findViewById(R.id.chart2_switch);
this.resetAllGraphData = (Button) findViewById(R.id.resetAllGraph);
this.chart1Visi.setChecked(PSharedPreference.getBoolean(Graph.this, "C1_V", true));
this.chart2Visi.setChecked(PSharedPreference.getBoolean(Graph.this, "C2_V", true));
this.resetDailySwitch.setChecked(PSharedPreference.getBoolean(Graph.this, "DAILY_RESET", false));
this.resetAllGraphData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoadAdClass1.showIAd(Graph.this);
Database database = new Database(Graph.this);
database.open();
database.deleteAll();
PSharedPreference.setLong(Graph.this, "NUMBER", 0L);
PSharedPreference.setLong(Graph.this, "GRPH_COUNTER", 0L);
MainActivity.counter = 0L;
MainActivity.graph_counter = 0L;
PToast.showT(Graph.this, "Reset");
database.close();
Graph.this.finish();
}
});
this.resetDailySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
PSharedPreference.setBoolean(Graph.this, "DAILY_RESET", z);
}
});
this.chart1Visi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
if (z) {
PSharedPreference.setBoolean(Graph.this, "C1_V", true);
Graph.this.chart1.setVisibility(0);
} else {
PSharedPreference.setBoolean(Graph.this, "C1_V", false);
Graph.this.chart1.setVisibility(8);
}
}
});
this.chart2Visi.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
if (z) {
PSharedPreference.setBoolean(Graph.this, "C2_V", true);
Graph.this.chart2.setVisibility(0);
} else {
PSharedPreference.setBoolean(Graph.this, "C2_V", false);
Graph.this.chart2.setVisibility(8);
}
}
});
PSetTypeface.setTextView(this.c, this.close, "sweetedge_lib.otf");
this.close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoadAdClass1.showIAd(Graph.this);
C1CustomDialogClass.this.dismiss();
}
});
}
}
public void ShowSetting_DialogScreen(Context context) {
new C1CustomDialogClass(this).show();
}
}