正在查看: Adobe Acrobat v15.3 应用的 ARSettingsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Adobe Acrobat v15.3 应用的 ARSettingsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.adobe.reader.misc;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.view.MenuItem;
import android.widget.Toast;
import com.adobe.a.by;
import com.adobe.libs.buildingblocks.utils.m;
import com.adobe.libs.c.a.f;
import com.adobe.libs.services.a.g;
import com.adobe.libs.services.auth.d;
import com.adobe.libs.services.d.b;
import com.adobe.libs.services.h.a;
import com.adobe.libs.services.h.n;
import com.adobe.reader.R;
import com.adobe.reader.analytics.ARDCMAnalytics;
import com.adobe.reader.comments.ARCommentsManager;
import com.adobe.reader.config.ARConstants;
import com.adobe.reader.filebrowser.ARFileBrowserUtils;
import com.adobe.reader.services.auth.ARServicesAccount;
import com.adobe.reader.services.blueheron.ARBlueHeronMoveCacheAsyncTask;
import com.adobe.reader.viewer.ARViewerActivity;
import java.io.File;
public class ARSettingsActivity extends f implements SharedPreferences.OnSharedPreferenceChangeListener, ARBlueHeronMoveCacheAsyncTask.MoveCacheTaskHandler {
public static final String DISPLAY_ON_KEY = "displayOnKey";
private EditTextPreference mAcrobatDotComCustomURIPreference;
private EditTextPreference mAuthorNamePreference;
private ListPreference mCacheLocationPreference;
private ListPreference mCloudMasterUriPreference;
private EditTextPreference mCustomIMSClientIDPreference;
private EditTextPreference mCustomIMSClientSecretPreference;
private CheckBoxPreference mDisplayAlwaysOn;
private CheckBoxPreference mOptInPreference;
private CheckBoxPreference mQuickTokenExpirationPreference;
private final String P_OPTIN_KEY = "optInKey";
private Intent mResultIntent = null;
private PreferenceScreen createPreferenceHierarchy() {
PreferenceScreen createPreferenceScreen = getPreferenceManager().createPreferenceScreen(this);
Resources resources = getApplicationContext().getResources();
this.mAuthorNamePreference = new EditTextPreference(this);
this.mAuthorNamePreference.setDialogTitle(resources.getString(R.string.IDS_AUTHOR_SETTING_TITLE));
this.mAuthorNamePreference.setKey(ARCommentsManager.P_AUTHOR_NAME);
this.mAuthorNamePreference.setTitle(resources.getString(R.string.IDS_AUTHOR_SETTING_TITLE));
this.mAuthorNamePreference.getEditText().setSingleLine();
setupAuthorNameSummary(getApplicationContext().getSharedPreferences(ARApp.ADOBE_READER_PREFERENCES, 0));
createPreferenceScreen.addPreference(this.mAuthorNamePreference);
this.mOptInPreference = new CheckBoxPreference(this);
this.mOptInPreference.setKey("optInKey");
this.mOptInPreference.setTitle(resources.getString(R.string.IDS_ANALYTICS_ALLOW_TRACKING_STR));
this.mOptInPreference.setSummary(resources.getString(R.string.IDS_ANALYTICS_PREF_MESSAGE_STR));
createPreferenceScreen.addPreference(this.mOptInPreference);
this.mOptInPreference.setChecked(ARDCMAnalytics.getInstance().analyticsPrivacyStatus() == by.MOBILE_PRIVACY_STATUS_OPT_IN);
this.mDisplayAlwaysOn = new CheckBoxPreference(this);
this.mDisplayAlwaysOn.setKey(DISPLAY_ON_KEY);
this.mDisplayAlwaysOn.setTitle(resources.getString(R.string.IDS_STAY_AWAKE));
this.mDisplayAlwaysOn.setSummary(resources.getString(R.string.IDS_STAY_AWAKE_MESSAGE));
createPreferenceScreen.addPreference(this.mDisplayAlwaysOn);
this.mCacheLocationPreference = new MyCacheListPreference(this);
this.mCacheLocationPreference.setKey("cacheLocationKey");
this.mCacheLocationPreference.setDialogTitle(a.a(resources.getString(R.string.IDS_CACHE_LOCATION_TITLE), d.getInstance().getAcrobatDotComName()));
this.mCacheLocationPreference.setTitle(a.a(resources.getString(R.string.IDS_CACHE_LOCATION_TITLE), d.getInstance().getAcrobatDotComName()));
updateCachePrefSummary();
CharSequence[] charSequenceArr = {resources.getString(R.string.IDS_CACHE_LOCATION_INTERNAL), resources.getString(R.string.IDS_CACHE_LOCATION_SDCARD)};
CharSequence[] charSequenceArr2 = {com.adobe.libs.services.h.d.CACHE_LOCATION_INTERNAL_VALUE.toString(), com.adobe.libs.services.h.d.CACHE_LOCATION_SDCARD_VALUE.toString()};
this.mCacheLocationPreference.setEntries(charSequenceArr);
this.mCacheLocationPreference.setEntryValues(charSequenceArr2);
createPreferenceScreen.addPreference(this.mCacheLocationPreference);
return createPreferenceScreen;
}
private void handleCacheLocationChange(SharedPreferences sharedPreferences) {
boolean z;
unregisterForSettingsChange();
boolean isSDCardAvailable = ARFileBrowserUtils.isSDCardAvailable();
File a2 = n.a();
Resources resources = ARApp.getAppContext().getResources();
if (!isSDCardAvailable || a2 == null) {
ARAlert.displayErrorDlg(this, null, resources.getString(R.string.IDS_SDCARD_NOT_AVAILABLE_STR), null);
z = false;
} else {
z = true;
}
switch (com.adobe.libs.services.h.d.a(sharedPreferences.getString("cacheLocationKey", com.adobe.libs.services.h.d.CACHE_LOCATION_SDCARD_VALUE.toString()))) {
case CACHE_LOCATION_INTERNAL_VALUE:
if (z) {
long a3 = m.a();
long a4 = com.adobe.libs.services.b.a.a(true);
if (a3 >= 52428800 + a4) {
g.a();
if (g.c() <= a4) {
new ARBlueHeronMoveCacheAsyncTask(this, true, a4, this).taskExecute(new Void[0]);
}
}
Toast.makeText(this, R.string.IDS_LOW_INTERNAL_MEMORY_STR, ARConstants.TOAST_MSG_DISPLAY_TIME_IN_MS).show();
z = false;
}
if (!z) {
com.adobe.libs.services.b.a.a(com.adobe.libs.services.h.d.CACHE_LOCATION_SDCARD_VALUE, false, -1L);
updateCachePrefSummary();
registerForSettingsChange();
break;
}
break;
case CACHE_LOCATION_SDCARD_VALUE:
if (z) {
long b = m.b();
long a5 = com.adobe.libs.services.b.a.a(false);
if (b >= 52428800 + a5) {
g.a();
if (g.c() <= a5) {
new ARBlueHeronMoveCacheAsyncTask(this, false, a5, this).taskExecute(new Void[0]);
}
}
Toast.makeText(this, R.string.IDS_LOW_INTERNAL_MEMORY_STR, ARConstants.TOAST_MSG_DISPLAY_TIME_IN_MS).show();
z = false;
}
if (!z) {
com.adobe.libs.services.b.a.a(com.adobe.libs.services.h.d.CACHE_LOCATION_INTERNAL_VALUE, false, -1L);
updateCachePrefSummary();
registerForSettingsChange();
break;
}
break;
}
}
private void handleCloudMasterUriChange() {
com.adobe.libs.services.a.a.a().d();
b.a().b = false;
ARServicesAccount.getInstance().removeAccount();
}
private void registerForSettingsChange() {
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
private void setupAuthorNameSummary(SharedPreferences sharedPreferences) {
String string = sharedPreferences.getString(ARCommentsManager.P_AUTHOR_NAME, null);
Resources resources = ARApp.getAppContext().getResources();
String string2 = resources.getString(R.string.IDS_DEFAULT_AUTHOR_STR);
if (string == null || string.equals(string2)) {
this.mAuthorNamePreference.setSummary(resources.getString(R.string.IDS_AUTHOR_SETTING_SUMMARY));
} else {
this.mAuthorNamePreference.setSummary(string);
}
}
private void unregisterForSettingsChange() {
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
}
private void updateCachePrefSummary() {
Resources resources = getApplicationContext().getResources();
switch (com.adobe.libs.services.b.a.a()) {
case CACHE_LOCATION_INTERNAL_VALUE:
this.mCacheLocationPreference.setSummary(resources.getString(R.string.IDS_CACHE_LOCATION_SUMMARY_INTERNAL));
this.mCacheLocationPreference.setValue(com.adobe.libs.services.h.d.CACHE_LOCATION_INTERNAL_VALUE.toString());
break;
case CACHE_LOCATION_SDCARD_VALUE:
this.mCacheLocationPreference.setSummary(resources.getString(R.string.IDS_CACHE_LOCATION_SUMMARY_SDCARD));
this.mCacheLocationPreference.setValue(com.adobe.libs.services.h.d.CACHE_LOCATION_SDCARD_VALUE.toString());
break;
}
}
private void updateOptIn(SharedPreferences sharedPreferences) {
ARDCMAnalytics.getInstance().updateOptInFromSettings(sharedPreferences.getBoolean("optInKey", false) ? 1 : 0);
}
private void updatePreferenceSummary(SharedPreferences sharedPreferences, String str, Preference preference, String str2) {
String string = sharedPreferences.getString(str, null);
if (string == null || string.isEmpty()) {
preference.setSummary(str2);
} else {
preference.setSummary(string);
}
}
@Override
public void onBackPressed() {
if (this.mResultIntent != null) {
setResult(-1, this.mResultIntent);
}
super.onBackPressed();
}
@Override
public void onCreateRAW(Bundle bundle) {
super.onCreateRAW(null);
getActionBar().setDisplayHomeAsUpEnabled(true);
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setSharedPreferencesName(ARApp.ADOBE_READER_PREFERENCES);
preferenceManager.setSharedPreferencesMode(0);
setPreferenceScreen(createPreferenceHierarchy());
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onDestroyRAW() {
getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
super.onDestroyRAW();
}
@Override
public void onMoveCacheTaskCompletion() {
updateCachePrefSummary();
registerForSettingsChange();
}
@Override
public void onMoveCacheTaskStart() {
}
@Override
public void onMoveCacheTaskSuccess(String str, String str2) {
this.mResultIntent = new Intent();
this.mResultIntent.putExtra(ARViewerActivity.CLOUD_CACHE_SRC_DIR, str);
this.mResultIntent.putExtra(ARViewerActivity.CLOUD_CACHE_DEST_DIR, str2);
}
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
if (this.mResultIntent != null) {
setResult(-1, this.mResultIntent);
}
finish();
return true;
default:
return super.onOptionsItemSelected(menuItem);
}
}
@Override
public void onPauseRAW() {
super.onPauseRAW();
ARDCMAnalytics.getInstance().pauseCollectingLifecycleData();
}
@Override
public void onResumeRAW() {
super.onResumeRAW();
ARDCMAnalytics.getInstance().collectLifecycleData();
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String str) {
if (str != null && str.equals(ARCommentsManager.P_AUTHOR_NAME)) {
setupAuthorNameSummary(sharedPreferences);
}
if (str != null && str.equals("optInKey")) {
updateOptIn(sharedPreferences);
}
if (str != null && str.equals(ARServicesAccount.MASTER_URI_KEY)) {
updatePreferenceSummary(sharedPreferences, ARServicesAccount.MASTER_URI_KEY, this.mCloudMasterUriPreference, ARServicesAccount.MASTER_URI_SETTINGS_SUMMARY);
handleCloudMasterUriChange();
}
if (str != null && str.equals("cacheLocationKey")) {
handleCacheLocationChange(sharedPreferences);
}
if (str != null && str.equals(ARServicesAccount.CUSTOM_ACROBAT_DOT_COM_URI_KEY)) {
updatePreferenceSummary(sharedPreferences, ARServicesAccount.CUSTOM_ACROBAT_DOT_COM_URI_KEY, this.mAcrobatDotComCustomURIPreference, ARServicesAccount.CUSTOM_ACROBAT_DOT_COM_URI_SUMMARY);
}
if (str != null && str.equals(ARServicesAccount.CUSTOM_IMS_CLIENT_ID_KEY)) {
updatePreferenceSummary(sharedPreferences, ARServicesAccount.CUSTOM_IMS_CLIENT_ID_KEY, this.mCustomIMSClientIDPreference, ARServicesAccount.CUSTOM_IMS_CLIENT_ID_SUMMARY);
}
if (str != null && str.equals(ARServicesAccount.CUSTOM_IMS_CLIENT_SECRET_KEY)) {
updatePreferenceSummary(sharedPreferences, ARServicesAccount.CUSTOM_IMS_CLIENT_SECRET_KEY, this.mCustomIMSClientSecretPreference, ARServicesAccount.CUSTOM_IMS_CLIENT_SECRET_SUMMARY);
}
if (str != null && str.equals(ARServicesAccount.QUICK_TOKEN_EXPIRATION_KEY) && ARServicesAccount.getInstance().isSignedIn()) {
new com.adobe.libs.services.auth.b().taskExecute(new Void[0]);
}
}
}