From 27bd1f81221b8c8e8047118a64c2beb7bc214bbb Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 20 七月 2021 13:45:08 +0800 Subject: [PATCH] 木瓜接入布丸系统完成 --- MGVideo/src/com/mugua/mgvideo/ui/mine/SettingsActivity.java | 530 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 266 insertions(+), 264 deletions(-) diff --git a/MGVideo/src/com/mugua/mgvideo/ui/mine/SettingsActivity.java b/MGVideo/src/com/mugua/mgvideo/ui/mine/SettingsActivity.java index 22be7b7..43ed08b 100644 --- a/MGVideo/src/com/mugua/mgvideo/ui/mine/SettingsActivity.java +++ b/MGVideo/src/com/mugua/mgvideo/ui/mine/SettingsActivity.java @@ -30,6 +30,7 @@ import com.bumptech.glide.Glide; import com.lcjian.library.util.common.StringUtils; import com.mugua.mgvideo.R; +import com.mugua.mgvideo.util.ConfigUtil; import com.umeng.analytics.MobclickAgent; import com.mugua.mgvideo.entity.SDCardEntity; import com.mugua.mgvideo.ui.BaseActivity; @@ -40,291 +41,292 @@ import com.ysh.wpc.appupdate.AppUpdate; public class SettingsActivity extends BaseActivity implements OnClickListener, - OnCheckedChangeListener { + OnCheckedChangeListener { - private TextView tv_top_bar_left; - private TextView tv_top_bar_middle; - private TextView tv_version_name;// 鐗堟湰鍙� + private TextView tv_top_bar_left; + private TextView tv_top_bar_middle; + private TextView tv_version_name;// 鐗堟湰鍙� - private CheckBox chb_only_wifi_download; - private RelativeLayout rl_clear_cache; - private RelativeLayout rl_about_us; - private RelativeLayout rl_check_update;// 妫�鏌ユ洿鏂� - private RelativeLayout rl_disclaimer; + private CheckBox chb_only_wifi_download; + private RelativeLayout rl_clear_cache; + private RelativeLayout rl_about_us; + private RelativeLayout rl_check_update;// 妫�鏌ユ洿鏂� + private RelativeLayout rl_disclaimer; - private Button btn_exit;// 绂诲紑鎸夐挳 - private View view_sdcard; - private TextView tv_mobile; - private TextView tv_sdcard; - private CheckBox cb_mobile; - private CheckBox cb_sdcard; + private Button btn_exit;// 绂诲紑鎸夐挳 + private View view_sdcard; + private TextView tv_mobile; + private TextView tv_sdcard; + private CheckBox cb_mobile; + private CheckBox cb_sdcard; - private void chageSize(TextView tv, int start, int end) { - SpannableStringBuilder spanBuilder = new SpannableStringBuilder(tv - .getText().toString()); + private void chageSize(TextView tv, int start, int end) { + SpannableStringBuilder spanBuilder = new SpannableStringBuilder(tv + .getText().toString()); - spanBuilder.setSpan(new TextAppearanceSpan(null, 0, getResources() - .getDimensionPixelSize(R.dimen.alphabet_size), null, null), - start, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE); - tv.setText(spanBuilder); - } + spanBuilder.setSpan(new TextAppearanceSpan(null, 0, getResources() + .getDimensionPixelSize(R.dimen.alphabet_size), null, null), + start, end, Spanned.SPAN_EXCLUSIVE_INCLUSIVE); + tv.setText(spanBuilder); + } - /** 鍒濆鍖栧唴瀛樻樉绀� */ - private void initStorageView() { + /** + * 鍒濆鍖栧唴瀛樻樉绀� + */ + private void initStorageView() { - tv_mobile.setText("鎵嬫満瀛樺偍: 鎬婚噺:" - + SDCardUtil.getSotrageSize(SDCardUtil - .getTotalExternalMemorySize() / (1024 * 1024)) - + " 鍙敤:" - + SDCardUtil.getSotrageSize(SDCardUtil - .getAvailableExternalMemorySize() / (1024 * 1024))); - chageSize(tv_mobile, 5, tv_mobile.getText().length()); - SDCardEntity entity = SDCardUtil.getSDCardPath(this); - if (entity == null) {// 娌℃湁澶栭儴瀛樺偍鍗� - view_sdcard.setVisibility(View.GONE); - cb_mobile.setVisibility(View.GONE); - } else { - tv_sdcard.setText("SD鍗″瓨鍌�: 鎬婚噺:" - + SDCardUtil.getSotrageSize(entity.getTotalSize() - / (1024 * 1024)) - + " 鍙敤:" - + SDCardUtil.getSotrageSize(entity.getAvailableSize() - / (1024 * 1024))); - chageSize(tv_sdcard, 6, tv_sdcard.getText().length()); - view_sdcard.setVisibility(View.VISIBLE); - cb_mobile.setVisibility(View.VISIBLE); - if (SDCardUtil.getDeaultStorage(this) == SDCardUtil.STORAGE_SDCARD) { - cb_sdcard.setChecked(true); - cb_mobile.setChecked(false); - } else { - cb_sdcard.setChecked(false); - cb_mobile.setChecked(true); - } - } - } + tv_mobile.setText("鎵嬫満瀛樺偍: 鎬婚噺:" + + SDCardUtil.getSotrageSize(SDCardUtil + .getTotalExternalMemorySize() / (1024 * 1024)) + + " 鍙敤:" + + SDCardUtil.getSotrageSize(SDCardUtil + .getAvailableExternalMemorySize() / (1024 * 1024))); + chageSize(tv_mobile, 5, tv_mobile.getText().length()); + SDCardEntity entity = SDCardUtil.getSDCardPath(this); + if (entity == null) {// 娌℃湁澶栭儴瀛樺偍鍗� + view_sdcard.setVisibility(View.GONE); + cb_mobile.setVisibility(View.GONE); + } else { + tv_sdcard.setText("SD鍗″瓨鍌�: 鎬婚噺:" + + SDCardUtil.getSotrageSize(entity.getTotalSize() + / (1024 * 1024)) + + " 鍙敤:" + + SDCardUtil.getSotrageSize(entity.getAvailableSize() + / (1024 * 1024))); + chageSize(tv_sdcard, 6, tv_sdcard.getText().length()); + view_sdcard.setVisibility(View.VISIBLE); + cb_mobile.setVisibility(View.VISIBLE); + if (SDCardUtil.getDeaultStorage(this) == SDCardUtil.STORAGE_SDCARD) { + cb_sdcard.setChecked(true); + cb_mobile.setChecked(false); + } else { + cb_sdcard.setChecked(false); + cb_mobile.setChecked(true); + } + } + } - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.settings_activity); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.settings_activity); - view_sdcard = findViewById(R.id.rl_storage_sdcard); - tv_mobile = (TextView) findViewById(R.id.tv_storage_mobile); - tv_sdcard = (TextView) findViewById(R.id.tv_storage_sdcard); - cb_mobile = (CheckBox) findViewById(R.id.cb_storage_mobile); - cb_sdcard = (CheckBox) findViewById(R.id.cb_storage_sdcard); - cb_mobile.setOnCheckedChangeListener(this); - cb_sdcard.setOnCheckedChangeListener(this); + view_sdcard = findViewById(R.id.rl_storage_sdcard); + tv_mobile = (TextView) findViewById(R.id.tv_storage_mobile); + tv_sdcard = (TextView) findViewById(R.id.tv_storage_sdcard); + cb_mobile = (CheckBox) findViewById(R.id.cb_storage_mobile); + cb_sdcard = (CheckBox) findViewById(R.id.cb_storage_sdcard); + cb_mobile.setOnCheckedChangeListener(this); + cb_sdcard.setOnCheckedChangeListener(this); - tv_top_bar_left = (TextView) findViewById(R.id.tv_top_bar_left); - tv_top_bar_middle = (TextView) findViewById(R.id.tv_top_bar_middle); - tv_top_bar_left.setText("杩斿洖"); - tv_top_bar_middle.setText("璁剧疆"); + tv_top_bar_left = (TextView) findViewById(R.id.tv_top_bar_left); + tv_top_bar_middle = (TextView) findViewById(R.id.tv_top_bar_middle); + tv_top_bar_left.setText("杩斿洖"); + tv_top_bar_middle.setText("璁剧疆"); - tv_top_bar_left.setOnClickListener(this); + tv_top_bar_left.setOnClickListener(this); - chb_only_wifi_download = (CheckBox) findViewById(R.id.chb_only_wifi_download); - rl_clear_cache = (RelativeLayout) findViewById(R.id.rl_clear_cache); - rl_disclaimer = (RelativeLayout) findViewById(R.id.rl_disclaimer); - rl_about_us = (RelativeLayout) findViewById(R.id.rl_about_us); - rl_check_update = (RelativeLayout) findViewById(R.id.rl_check_update); - tv_version_name = (TextView) findViewById(R.id.tv_version_name); - btn_exit = (Button) findViewById(R.id.setting_btn_exit); + chb_only_wifi_download = (CheckBox) findViewById(R.id.chb_only_wifi_download); + rl_clear_cache = (RelativeLayout) findViewById(R.id.rl_clear_cache); + rl_disclaimer = (RelativeLayout) findViewById(R.id.rl_disclaimer); + rl_about_us = (RelativeLayout) findViewById(R.id.rl_about_us); + rl_check_update = (RelativeLayout) findViewById(R.id.rl_check_update); + tv_version_name = (TextView) findViewById(R.id.tv_version_name); + btn_exit = (Button) findViewById(R.id.setting_btn_exit); - btn_exit.setOnClickListener(this); - rl_clear_cache.setOnClickListener(this); - rl_disclaimer.setOnClickListener(this); - rl_about_us.setOnClickListener(this); - rl_check_update.setOnClickListener(this); + btn_exit.setOnClickListener(this); + rl_clear_cache.setOnClickListener(this); + rl_disclaimer.setOnClickListener(this); + rl_about_us.setOnClickListener(this); + rl_check_update.setOnClickListener(this); - final SharedPreferences settings = getSharedPreferences("settings", - Context.MODE_PRIVATE); - chb_only_wifi_download.setChecked(settings.getBoolean( - "only_wifi_download", true)); - chb_only_wifi_download - .setOnCheckedChangeListener(new OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - settings.edit() - .putBoolean("only_wifi_download", isChecked) - .commit(); - } - }); - initStorageView(); - tv_version_name.setText("鐗堟湰鍙�:" + getVersionName(this)); - // 绂诲紑鎸夐挳鏄惁鏄剧ず - if (StringUtils.isEmpty(getSharedPreferences("user", - Context.MODE_PRIVATE).getString("LoginUid", ""))) {// 濡傛灉涓虹┖瀛楃 - btn_exit.setVisibility(View.GONE); - } - } + final SharedPreferences settings = getSharedPreferences("settings", + Context.MODE_PRIVATE); + chb_only_wifi_download.setChecked(settings.getBoolean( + "only_wifi_download", true)); + chb_only_wifi_download + .setOnCheckedChangeListener(new OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { + settings.edit() + .putBoolean("only_wifi_download", isChecked) + .commit(); + } + }); + initStorageView(); + tv_version_name.setText("鐗堟湰鍙�:" + getVersionName(this)); + // 绂诲紑鎸夐挳鏄惁鏄剧ず + if (StringUtils.isEmpty(getSharedPreferences("user", + Context.MODE_PRIVATE).getString("LoginUid", ""))) {// 濡傛灉涓虹┖瀛楃 + btn_exit.setVisibility(View.GONE); + } + } - /*** 鑾峰彇鐗堟湰鍙� */ - public static String getVersionName(Context context) { - try { - PackageInfo pi = context.getPackageManager().getPackageInfo( - context.getPackageName(), 0); - return pi.versionName; - } catch (NameNotFoundException e) { - e.printStackTrace(); - return ""; - } - } + /*** 鑾峰彇鐗堟湰鍙� */ + public static String getVersionName(Context context) { + try { + PackageInfo pi = context.getPackageManager().getPackageInfo( + context.getPackageName(), 0); + return pi.versionName; + } catch (NameNotFoundException e) { + e.printStackTrace(); + return ""; + } + } - @Override - public void onResume() { - super.onResume(); - BadgeView mBadge = new BadgeView(this, tv_version_name); - mBadge.setBackgroundResource(R.drawable.ic_red_dot); - mBadge.setTextSize(1); - mBadge.setText(""); - SharedPreferences preferences = this.getSharedPreferences("update", - Context.MODE_PRIVATE); - boolean mStatus = preferences.getBoolean("status", false); - if (mStatus) { - mBadge.show(); - } else { - mBadge.hide(); - } - MobclickAgent.onPageStart("璁剧疆椤�"); - } + @Override + public void onResume() { + super.onResume(); + BadgeView mBadge = new BadgeView(this, tv_version_name); + mBadge.setBackgroundResource(R.drawable.ic_red_dot); + mBadge.setTextSize(1); + mBadge.setText(""); + SharedPreferences preferences = this.getSharedPreferences("update", + Context.MODE_PRIVATE); + boolean mStatus = preferences.getBoolean("status", false); + if (mStatus) { + mBadge.show(); + } else { + mBadge.hide(); + } + MobclickAgent.onPageStart("璁剧疆椤�"); + } - @Override - public void onPause() { - super.onPause(); - MobclickAgent.onPageEnd("璁剧疆椤�"); - } + @Override + public void onPause() { + super.onPause(); + MobclickAgent.onPageEnd("璁剧疆椤�"); + } - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.setting_btn_exit:// 鐐瑰嚮绂诲紑 - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage("纭畾瑕侀��鍑虹櫥褰曞悧锛�") - .setNegativeButton("鍙栨秷", null) - .setPositiveButton("纭畾", - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - Editor edit = getSharedPreferences("user", - Context.MODE_PRIVATE).edit(); - edit.putString("LoginUid", ""); - edit.commit(); - MineFragment.isLogin = false;// 鏀逛负鏈櫥褰曠姸鎬� - finish(); - } - }); - builder.create().show(); - break; - case R.id.rl_check_update:// 鐐瑰嚮妫�鏌ユ洿鏂� - AppUpdate.setAppUpdateActivity(this); - Map<String, String> map = new HashMap<>(); - map.put("360", "6c8349cc7260ae62e3b1396831a8398f"); - map.put("QQ", "d9d4f495e875a2e075a1a4a6e1b9770f"); - map.put("GuanWang", "a5771bce93e200c36f7cd9dfd0e5deaa"); - if ("360".equalsIgnoreCase(getChannelName())) { - AppUpdate.setAppUpdateKey(map.get("360")); - } else if ("QQ".equalsIgnoreCase(getChannelName())) { - AppUpdate.setAppUpdateKey(map.get("QQ")); - } else { - AppUpdate.setAppUpdateKey(map.get("GuanWang")); - } - AppUpdate.initAppUpdate(); - break; - case R.id.tv_top_bar_left: { - finish(); - } - break; - case R.id.rl_clear_cache: { - AlertDialog.Builder builder2 = new AlertDialog.Builder(this); - builder2.setMessage("纭畾娓呯┖鍥剧墖缂撳瓨锛�") - .setNegativeButton("鍙栨秷", null) - .setPositiveButton("纭畾", - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int which) { - new Thread(new Runnable() { - @Override - public void run() { - Glide.get(SettingsActivity.this) - .clearDiskCache(); - } - }).start(); - // ImageLoader.getInstance().clearDiskCache(); - Toast.makeText(SettingsActivity.this, - "缂撳瓨宸叉竻绌�", Toast.LENGTH_SHORT).show(); - } - }); - builder2.create().show(); - } - break; - case R.id.rl_disclaimer: { - Intent intent = new Intent(this, BrowserActivity.class); - intent.putExtra("url", BeibeiConstant.HOST + "/new_video/" - + "api_disclaimer.jsp?package=" + getPackageName()); - startActivity(intent); - } - break; - case R.id.rl_about_us: { - Intent intent = new Intent(this, BrowserActivity.class); - intent.putExtra("url", BeibeiConstant.HOST + "/new_video/" - + "api_about_us.jsp?package=" + getPackageName()); - startActivity(intent); - } - break; - default: - break; - } - } + @Override + public void onClick(View v) { + switch (v.getId()) { + case R.id.setting_btn_exit:// 鐐瑰嚮绂诲紑 + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage("纭畾瑕侀��鍑虹櫥褰曞悧锛�") + .setNegativeButton("鍙栨秷", null) + .setPositiveButton("纭畾", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + Editor edit = getSharedPreferences("user", + Context.MODE_PRIVATE).edit(); + edit.putString("LoginUid", ""); + edit.commit(); + MineFragment.isLogin = false;// 鏀逛负鏈櫥褰曠姸鎬� + finish(); + } + }); + builder.create().show(); + break; + case R.id.rl_check_update:// 鐐瑰嚮妫�鏌ユ洿鏂� + AppUpdate.setAppUpdateActivity(this); + Map<String, String> map = new HashMap<>(); + map.put("360", "6c8349cc7260ae62e3b1396831a8398f"); + map.put("QQ", "d9d4f495e875a2e075a1a4a6e1b9770f"); + map.put("GuanWang", "a5771bce93e200c36f7cd9dfd0e5deaa"); + if ("360".equalsIgnoreCase(getChannelName())) { + AppUpdate.setAppUpdateKey(map.get("360")); + } else if ("QQ".equalsIgnoreCase(getChannelName())) { + AppUpdate.setAppUpdateKey(map.get("QQ")); + } else { + AppUpdate.setAppUpdateKey(map.get("GuanWang")); + } + AppUpdate.initAppUpdate(); + break; + case R.id.tv_top_bar_left: { + finish(); + } + break; + case R.id.rl_clear_cache: { + AlertDialog.Builder builder2 = new AlertDialog.Builder(this); + builder2.setMessage("纭畾娓呯┖鍥剧墖缂撳瓨锛�") + .setNegativeButton("鍙栨秷", null) + .setPositiveButton("纭畾", + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, + int which) { + new Thread(new Runnable() { + @Override + public void run() { + Glide.get(SettingsActivity.this) + .clearDiskCache(); + } + }).start(); + // ImageLoader.getInstance().clearDiskCache(); + Toast.makeText(SettingsActivity.this, + "缂撳瓨宸叉竻绌�", Toast.LENGTH_SHORT).show(); + } + }); + builder2.create().show(); + } + break; + case R.id.rl_disclaimer: { + Intent intent = new Intent(this, BrowserActivity.class); + intent.putExtra("url", BeibeiConstant.HOST + "/new_video/" + + "api_disclaimer.jsp?package=" + getPackageName()); + startActivity(intent); + } + break; + case R.id.rl_about_us: { + Intent intent = new Intent(this, BrowserActivity.class); + intent.putExtra("url", getString(R.string.about_us_url)); + startActivity(intent); + } + break; + default: + break; + } + } - private String getChannelName() { - String channelName = null; - try { - PackageManager packageManager = getPackageManager(); - if (packageManager != null) { - // 娉ㄦ剰姝ゅ涓篈pplicationInfo 鑰屼笉鏄� - // ActivityInfo,鍥犱负鍙嬬洘璁剧疆鐨刴eta-data鏄湪application鏍囩涓紝鑰屼笉鏄煇activity鏍囩涓紝鎵�浠ョ敤ApplicationInfo - ApplicationInfo applicationInfo = packageManager - .getApplicationInfo( - SettingsActivity.this.getPackageName(), - PackageManager.GET_META_DATA); - if (applicationInfo != null) { - if (applicationInfo.metaData != null) { - channelName = applicationInfo.metaData - .getString("UMENG_CHANNEL"); - } - } + private String getChannelName() { + String channelName = null; + try { + PackageManager packageManager = getPackageManager(); + if (packageManager != null) { + // 娉ㄦ剰姝ゅ涓篈pplicationInfo 鑰屼笉鏄� + // ActivityInfo,鍥犱负鍙嬬洘璁剧疆鐨刴eta-data鏄湪application鏍囩涓紝鑰屼笉鏄煇activity鏍囩涓紝鎵�浠ョ敤ApplicationInfo + ApplicationInfo applicationInfo = packageManager + .getApplicationInfo( + SettingsActivity.this.getPackageName(), + PackageManager.GET_META_DATA); + if (applicationInfo != null) { + if (applicationInfo.metaData != null) { + channelName = applicationInfo.metaData + .getString("UMENG_CHANNEL"); + } + } - } - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } - return channelName; - } + } + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + return channelName; + } - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (buttonView.getId() == R.id.cb_storage_mobile) { - if (isChecked) { - SDCardUtil.setDeaultStorage(this, SDCardUtil.STORAGE_MOBILE); - cb_sdcard.setChecked(false); - } - } else { - if (isChecked) { - SDCardUtil.setDeaultStorage(this, SDCardUtil.STORAGE_SDCARD); - cb_mobile.setChecked(false); - } - } + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (buttonView.getId() == R.id.cb_storage_mobile) { + if (isChecked) { + SDCardUtil.setDeaultStorage(this, SDCardUtil.STORAGE_MOBILE); + cb_sdcard.setChecked(false); + } + } else { + if (isChecked) { + SDCardUtil.setDeaultStorage(this, SDCardUtil.STORAGE_SDCARD); + cb_mobile.setChecked(false); + } + } - } + } - @Override - protected void onDestroy() { - // TODO Auto-generated method stub - super.onDestroy(); - AppUpdate.destoryAppUpdate(); - } + @Override + protected void onDestroy() { + // TODO Auto-generated method stub + super.onDestroy(); + AppUpdate.destoryAppUpdate(); + } } -- Gitblit v1.8.0