analysis: full official-app reverse artifacts (jadx sources, ghidra libcxsdk decomp, authoritative protocol conclusions) + docs
This commit is contained in:
@@ -0,0 +1,445 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.ExifInterface;
|
||||
import android.media.MediaMetadataRetriever;
|
||||
import android.media.ThumbnailUtils;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.support.v4.media.session.PlaybackStateCompat;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import cn.com.magnity.magnitycx.QueryDialogFragment;
|
||||
import cn.com.magnity.magnitycx.sdk.BitmapUtilities;
|
||||
import cn.com.magnity.magnitycx.sdk.GlobalFunc;
|
||||
import com.baidu.mobstat.StatService;
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MediaSingleActivity extends AppCompatActivity implements QueryDialogFragment.DelegateQueryResult {
|
||||
public static final String MEDIAINDEX = "mediaIndex";
|
||||
public static final String MEDIANAMELIST = "mediaNameList";
|
||||
public static final String MEDIAWINDOWFLAG = "mediaWindowFlag";
|
||||
private Button btnDel_;
|
||||
private Button btnInfo_;
|
||||
private Button btnShare_;
|
||||
private int currentIndex_;
|
||||
private ArrayList<String> fileNames_;
|
||||
private boolean isVideo_;
|
||||
private MagClickListener magClickListener_;
|
||||
private int mediaWindowFlag_;
|
||||
private ViewPager viewPager_;
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.BaseFragmentActivityGingerbread, android.app.Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_media_single);
|
||||
if (savedInstanceState != null) {
|
||||
this.mediaWindowFlag_ = savedInstanceState.getInt(MEDIAWINDOWFLAG);
|
||||
this.currentIndex_ = savedInstanceState.getInt(MEDIAINDEX);
|
||||
this.fileNames_ = savedInstanceState.getStringArrayList(MEDIANAMELIST);
|
||||
} else {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
this.mediaWindowFlag_ = intent.getIntExtra(MEDIAWINDOWFLAG, 0);
|
||||
this.currentIndex_ = intent.getIntExtra(MEDIAINDEX, 0);
|
||||
this.fileNames_ = intent.getStringArrayListExtra(MEDIANAMELIST);
|
||||
} else {
|
||||
this.mediaWindowFlag_ = 0;
|
||||
this.currentIndex_ = 0;
|
||||
this.fileNames_ = new ArrayList<>();
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
GlobalFunc.updateFileList(this.fileNames_);
|
||||
}
|
||||
}
|
||||
setTitle(getResources().getString(R.string.mediaHouse) + " " + Integer.toString(this.currentIndex_ + 1) + "/" + this.fileNames_.size());
|
||||
this.btnShare_ = (Button) findViewById(R.id.id_btn_social_share);
|
||||
this.btnInfo_ = (Button) findViewById(R.id.id_btn_meida_info);
|
||||
this.btnDel_ = (Button) findViewById(R.id.id_btn_media_delete);
|
||||
this.viewPager_ = (ViewPager) findViewById(R.id.id_media_viewpager);
|
||||
this.viewPager_.setAdapter(new MediaPageAdapter());
|
||||
this.viewPager_.addOnPageChangeListener(new MediaPageListener());
|
||||
this.viewPager_.setPageMargin(30);
|
||||
this.viewPager_.setCurrentItem(this.currentIndex_);
|
||||
this.viewPager_.setPageTransformer(true, new DepthPageTransformer());
|
||||
if (this.currentIndex_ < this.fileNames_.size()) {
|
||||
GlobalFunc globalFunc2 = MagApplication.globalFunc;
|
||||
this.isVideo_ = GlobalFunc.guessMediaTypeBySuffix(this.fileNames_.get(this.currentIndex_)) == 1;
|
||||
}
|
||||
this.magClickListener_ = new MagClickListener();
|
||||
this.btnShare_.setOnClickListener(this.magClickListener_);
|
||||
this.btnInfo_.setOnClickListener(this.magClickListener_);
|
||||
this.btnDel_.setOnClickListener(this.magClickListener_);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
StatService.onPageEnd(getApplicationContext(), "单个媒体页面");
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
showInfoWhenFileNotExist();
|
||||
StatService.onPageStart(getApplicationContext(), "单个媒体页面");
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void showInfoWhenFileNotExist() {
|
||||
File file = new File(MagApplication.magParameter.mediaDir + File.separator + this.fileNames_.get(this.currentIndex_));
|
||||
if (file != null && !file.exists()) {
|
||||
Toast.makeText(getApplicationContext(), R.string.fileDeleted, 0).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putInt(MEDIAWINDOWFLAG, this.mediaWindowFlag_);
|
||||
outState.putInt(MEDIAINDEX, this.currentIndex_);
|
||||
outState.putStringArrayList(MEDIANAMELIST, this.fileNames_);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.meida_single_menu, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.id_action_media_expand /* 2131624225 */:
|
||||
if (this.mediaWindowFlag_ == 1) {
|
||||
super.onBackPressed();
|
||||
break;
|
||||
} else {
|
||||
finish();
|
||||
Intent intent = new Intent(this, (Class<?>) MediaActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public Bitmap decodeBitmap(String pathName) {
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.outWidth = 0;
|
||||
opts.outHeight = 0;
|
||||
opts.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(pathName, opts);
|
||||
Point outSize = new Point();
|
||||
MagApplication.windowManager.getDefaultDisplay().getSize(outSize);
|
||||
int r1 = ((opts.outWidth - 1) / outSize.x) + 1;
|
||||
int r2 = ((opts.outHeight - 1) / outSize.y) + 1;
|
||||
opts.inSampleSize = Math.max(Math.max(r1, r2), 1);
|
||||
opts.inJustDecodeBounds = false;
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(pathName, opts);
|
||||
if (bitmap == null) {
|
||||
return ThumbnailUtils.createVideoThumbnail(pathName, 1);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private File getMediaStoragePath(Context context) {
|
||||
File file;
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ("mounted".equals(state) && (file = new File(Environment.getExternalStorageDirectory(), "magnity/Cx/media")) != null) {
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
return file;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void socialShare() {
|
||||
Uri uri;
|
||||
File f = new File(getMediaStoragePath(this), this.fileNames_.get(this.currentIndex_));
|
||||
if (f != null && f.isFile() && (uri = FileProvider.getUriForFile(this, "cn.com.magnity.magnitycx.fileprovider", f)) != null) {
|
||||
Intent intent = new Intent("android.intent.action.SEND");
|
||||
intent.setType(this.isVideo_ ? "video/*" : "image/*");
|
||||
intent.putExtra("android.intent.extra.STREAM", uri);
|
||||
intent.addFlags(1);
|
||||
startActivity(Intent.createChooser(intent, getResources().getString(R.string.mediaSocialShare)));
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> getMediaInfos() {
|
||||
File f;
|
||||
Point pt;
|
||||
ArrayList<String> infos = new ArrayList<>();
|
||||
String time = null;
|
||||
String size = null;
|
||||
String reso = null;
|
||||
String duration = null;
|
||||
String name = this.fileNames_.get(this.currentIndex_);
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + name;
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
int mediaType = GlobalFunc.guessMediaTypeBySuffix(name);
|
||||
if (mediaType == 0) {
|
||||
try {
|
||||
ExifInterface exifInterface = new ExifInterface(pathName);
|
||||
time = exifInterface.getAttribute("DateTimeDigitized");
|
||||
size = null;
|
||||
reso = null;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else if (mediaType == 1) {
|
||||
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
|
||||
try {
|
||||
mmr.setDataSource(pathName);
|
||||
time = null;
|
||||
size = null;
|
||||
String w = mmr.extractMetadata(18);
|
||||
String h = mmr.extractMetadata(19);
|
||||
if (w != null && h != null && w != "0" && h != "0") {
|
||||
reso = w + " x " + h;
|
||||
}
|
||||
duration = mmr.extractMetadata(9);
|
||||
if (duration != null) {
|
||||
long sec = Integer.parseInt(duration) / 1000;
|
||||
long hour = sec / 3600;
|
||||
long min = (sec - (3600 * hour)) / 60;
|
||||
duration = String.format("%02d:%02d:%02d", Long.valueOf(hour), Long.valueOf(min), Long.valueOf((sec - (3600 * hour)) - (60 * min)));
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
}
|
||||
} else {
|
||||
time = null;
|
||||
size = null;
|
||||
reso = null;
|
||||
}
|
||||
if ((time == null || size == null || reso == null) && (f = new File(pathName)) != null && f.isFile()) {
|
||||
if (time == null) {
|
||||
Date dt = new Date(f.lastModified());
|
||||
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
time = ft.format(dt);
|
||||
}
|
||||
if (size == null) {
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
long bytes = f.length();
|
||||
if (bytes < PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID) {
|
||||
size = df.format(bytes) + "B";
|
||||
} else if (bytes < 1048576) {
|
||||
size = df.format(bytes / 1024.0f) + "KB";
|
||||
} else {
|
||||
size = df.format(bytes / 1048576.0f) + "MB";
|
||||
}
|
||||
}
|
||||
if (reso == null && (pt = BitmapUtilities.getBitmapSize(pathName)) != null) {
|
||||
reso = pt.x + " x " + pt.y;
|
||||
}
|
||||
}
|
||||
if (mediaType == 1) {
|
||||
infos.add("1");
|
||||
} else {
|
||||
infos.add("0");
|
||||
}
|
||||
infos.add(name);
|
||||
infos.add(time);
|
||||
infos.add(size);
|
||||
infos.add(duration);
|
||||
infos.add(reso);
|
||||
infos.add(pathName);
|
||||
return infos;
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.QueryDialogFragment.DelegateQueryResult
|
||||
public void onQueryResult(int result) {
|
||||
if (result == 1) {
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + this.fileNames_.get(this.currentIndex_);
|
||||
File f = new File(pathName);
|
||||
if (f != null && f.isFile()) {
|
||||
f.delete();
|
||||
this.fileNames_.remove(this.currentIndex_);
|
||||
File f2 = new File(pathName.replace(".jpg", ".ddt"));
|
||||
if (f2 != null && f2.isFile()) {
|
||||
f2.delete();
|
||||
}
|
||||
if (this.fileNames_.isEmpty()) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
this.viewPager_.setAdapter(new MediaPageAdapter());
|
||||
if (this.currentIndex_ > this.fileNames_.size() - 1) {
|
||||
this.viewPager_.setCurrentItem(this.currentIndex_ - 1);
|
||||
} else {
|
||||
this.viewPager_.setCurrentItem(this.currentIndex_);
|
||||
}
|
||||
showInfoWhenFileNotExist();
|
||||
setTitle(getResources().getString(R.string.mediaHouse) + " " + Integer.toString(this.currentIndex_ + 1) + "/" + this.fileNames_.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MagClickListener implements View.OnClickListener {
|
||||
private MagClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.id_btn_social_share /* 2131624072 */:
|
||||
MediaSingleActivity.this.socialShare();
|
||||
break;
|
||||
case R.id.id_btn_meida_info /* 2131624073 */:
|
||||
DialogFragmentMediaInfo dlgMediaInfo = DialogFragmentMediaInfo.newInstance(MediaSingleActivity.this.getMediaInfos());
|
||||
dlgMediaInfo.show(MediaSingleActivity.this.getSupportFragmentManager(), "dialogFragmentMediaInfo");
|
||||
break;
|
||||
case R.id.id_btn_media_delete /* 2131624074 */:
|
||||
QueryDialogFragment dlgMediaDel = QueryDialogFragment.newInstance(R.layout.dialog_fragment_query_delete_media);
|
||||
dlgMediaDel.show(MediaSingleActivity.this.getSupportFragmentManager(), "deleteMedia");
|
||||
break;
|
||||
case R.id.id_img_single /* 2131624185 */:
|
||||
if (MediaSingleActivity.this.isVideo_) {
|
||||
Intent intent = new Intent("android.intent.action.VIEW");
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + ((String) MediaSingleActivity.this.fileNames_.get(MediaSingleActivity.this.currentIndex_));
|
||||
intent.setDataAndType(Uri.parse("file:///" + pathName), "video/*");
|
||||
MagApplication.setUsbDeinitAllowed(false);
|
||||
if (intent.resolveActivity(MediaSingleActivity.this.getPackageManager()) != null) {
|
||||
MediaSingleActivity.this.startActivity(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MediaPageAdapter extends PagerAdapter {
|
||||
private MediaPageAdapter() {
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.PagerAdapter
|
||||
public int getCount() {
|
||||
return MediaSingleActivity.this.fileNames_.size();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.PagerAdapter
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
private void releaseImageViewResouce(ImageView imageView) {
|
||||
Drawable drawable;
|
||||
if (imageView != null && (drawable = imageView.getDrawable()) != null && (drawable instanceof BitmapDrawable)) {
|
||||
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
|
||||
Bitmap bitmap = bitmapDrawable.getBitmap();
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.PagerAdapter
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
View view = (View) object;
|
||||
if (view != null) {
|
||||
releaseImageViewResouce((ImageView) view.findViewById(R.id.id_img_single));
|
||||
container.removeView(view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.PagerAdapter
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
View view = MediaSingleActivity.this.getLayoutInflater().inflate(R.layout.include_media_single, (ViewGroup) null);
|
||||
String name = (String) MediaSingleActivity.this.fileNames_.get(position);
|
||||
ImageView img = (ImageView) view.findViewById(R.id.id_img_single);
|
||||
img.setImageBitmap(MediaSingleActivity.this.decodeBitmap(MagApplication.magParameter.mediaDir + File.separator + ((String) MediaSingleActivity.this.fileNames_.get(position))));
|
||||
ImageView videoLogo = (ImageView) view.findViewById(R.id.id_video_play_logo);
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
int type = GlobalFunc.guessMediaTypeBySuffix(name);
|
||||
if (type == 1) {
|
||||
videoLogo.setVisibility(0);
|
||||
} else {
|
||||
videoLogo.setVisibility(4);
|
||||
}
|
||||
img.setOnClickListener(MediaSingleActivity.this.magClickListener_);
|
||||
container.addView(view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
private class MediaPageListener implements ViewPager.OnPageChangeListener {
|
||||
private MediaPageListener() {
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.ViewPager.OnPageChangeListener
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.ViewPager.OnPageChangeListener
|
||||
public void onPageSelected(int position) {
|
||||
MediaSingleActivity.this.currentIndex_ = position;
|
||||
MediaSingleActivity mediaSingleActivity = MediaSingleActivity.this;
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
mediaSingleActivity.isVideo_ = GlobalFunc.guessMediaTypeBySuffix((String) MediaSingleActivity.this.fileNames_.get(position)) == 1;
|
||||
MediaSingleActivity.this.setTitle(MediaSingleActivity.this.getResources().getString(R.string.mediaHouse) + " " + Integer.toString(position + 1) + "/" + MediaSingleActivity.this.fileNames_.size());
|
||||
MediaSingleActivity.this.showInfoWhenFileNotExist();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.ViewPager.OnPageChangeListener
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
}
|
||||
}
|
||||
|
||||
public class DepthPageTransformer implements ViewPager.PageTransformer {
|
||||
private static final float MIN_SCALE = 0.75f;
|
||||
|
||||
public DepthPageTransformer() {
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.ViewPager.PageTransformer
|
||||
public void transformPage(View view, float position) {
|
||||
int pageWidth = view.getWidth();
|
||||
if (position < -1.0f) {
|
||||
view.setAlpha(0.0f);
|
||||
return;
|
||||
}
|
||||
if (position <= 0.0f) {
|
||||
view.setAlpha(1.0f);
|
||||
view.setTranslationX(0.0f);
|
||||
view.setScaleX(1.0f);
|
||||
view.setScaleY(1.0f);
|
||||
return;
|
||||
}
|
||||
if (position <= 1.0f) {
|
||||
view.setAlpha(1.0f - position);
|
||||
view.setTranslationX(pageWidth * (-position));
|
||||
float scaleFactor = MIN_SCALE + (0.25f * (1.0f - Math.abs(position)));
|
||||
view.setScaleX(scaleFactor);
|
||||
view.setScaleY(scaleFactor);
|
||||
return;
|
||||
}
|
||||
view.setAlpha(0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user