List of usage examples for android.content SharedPreferences getInt
int getInt(String key, int defValue);
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
private List<Map> restoreCheckList() { // check getListMem List<Map> tmpList = null; SharedPreferences shared = getSharedPreferences("mysettings", Context.MODE_PRIVATE); String check = "empty"; boolean stateGetList = shared.getBoolean("stateGetList", false); int indexList = shared.getInt("indexList", -1); if (stateGetList) { // Log.i("inCheck_satetGetList", "inCheck_stateGetList"); DBCarCheckList dbList = new DBCarCheckList(this); SQLiteDatabase sqliteList = dbList.getReadableDatabase(); String sqlList = "SELECT * FROM " + dbList.TABLE_NAME; Cursor cursor = sqliteList.rawQuery(sqlList, null); cursor.moveToFirst();//from w w w . java2s .co m int numRow = cursor.getCount(); String[] idList = new String[numRow]; int i = 0; int id = -1; String username = "empty"; String data = "empty"; while (cursor != null) { idList[i] = cursor.getString(0); i++; if (cursor.isLast()) break; cursor.moveToNext(); } // restore from save list String iD = idList[indexList]; sqlList = "SELECT * FROM " + dbList.TABLE_NAME + " WHERE id=" + iD; Cursor cursor2 = sqliteList.rawQuery(sqlList, null); cursor2.moveToFirst(); ExpandData ex = new ExpandData(getApplicationContext()); tmpList = ex.filterData(cursor2.getString(2)); ex.displayMap(tmpList.get(0), tmpList.get(1)); check = " , data : " + cursor2.getString(2); cursor2.close(); sqliteList.close(); dbList.close(); int[] expand = ex.getPercentAllList(); // IT'S WORK FOR TEST // **************************************************************** PercenPower = expand[0]; PercenEngine = expand[1]; PercenExterior = expand[2]; PercenInterior = expand[3]; PercenDocument = expand[4]; /*CheckPowerTotal = shared.getInt("CheckPowerTotal", 0); CheckEngineTotal = shared.getInt("CheckEngineTotal", 0); CheckExteriorTotal = shared.getInt("CheckExteriorTotal", 0); CheckInteriorTotal = shared.getInt("CheckInteriorTotal", 0); CheckDocumentTotal = shared.getInt("CheckDocumentTotal", 0);*/ // IT'S WORK FOR TEST // **************************************************************** } else { Log.i("inCheck_satetGetList", "out stateGetList"); } // Log.i("stateGetList2", "stateGetList >--->>" + stateGetList + check); // Log.i("indexList", "getIndexList >>>>>>> " + indexList); if (stateGetList) { Editor edit = shared.edit(); edit.clear(); edit.commit(); Checknumcheckbox(); edit.putInt("checknum", Checknum); edit.commit(); } return tmpList; }
From source file:com.ichi2.anki.DeckPicker.java
private void showStartupScreensAndDialogs(SharedPreferences preferences, int skip) { if (!AnkiDroidApp.isSdCardMounted()) { // SD card not mounted onSdCardNotMounted();//from www . j av a 2s . c o m } else if (!CollectionHelper.isCurrentAnkiDroidDirAccessible(this)) { // AnkiDroid directory inaccessible Intent i = new Intent(this, Preferences.class); startActivityWithoutAnimation(i); showSimpleSnackbar(R.string.directory_inaccessible, false); } else if (!BackupManager.enoughDiscSpace(CollectionHelper.getCurrentAnkiDroidDirectory(this))) { // Not enough space to do backup showDialogFragment(DeckPickerNoSpaceLeftDialog.newInstance()); } else if (preferences.getBoolean("noSpaceLeft", false)) { // No space left showDialogFragment(DeckPickerBackupNoSpaceLeftDialog.newInstance()); preferences.edit().putBoolean("noSpaceLeft", false).commit(); } else if (preferences.getString("lastVersion", "").equals("")) { // Fresh install preferences.edit().putString("lastVersion", VersionUtils.getPkgVersionName()).commit(); onFinishedStartup(); } else if (skip < 2 && !preferences.getString("lastVersion", "").equals(VersionUtils.getPkgVersionName())) { // AnkiDroid is being updated and a collection already exists. We check if we are upgrading // to a version that contains additions to the database integrity check routine that we would // like to run on all collections. A missing version number is assumed to be a fresh // installation of AnkiDroid and we don't run the check. int current = VersionUtils.getPkgVersionCode(); int previous; if (!preferences.contains("lastUpgradeVersion")) { // Fresh install previous = current; } else { try { previous = preferences.getInt("lastUpgradeVersion", current); } catch (ClassCastException e) { // Previous versions stored this as a string. String s = preferences.getString("lastUpgradeVersion", ""); // The last version of AnkiDroid that stored this as a string was 2.0.2. // We manually set the version here, but anything older will force a DB // check. if (s.equals("2.0.2")) { previous = 40; } else { previous = 0; } } } preferences.edit().putInt("lastUpgradeVersion", current).commit(); // Delete the media database made by any version before 2.3 beta due to upgrade errors. // It is rebuilt on the next sync or media check if (previous < 20300200) { File mediaDb = new File(CollectionHelper.getCurrentAnkiDroidDirectory(this), "collection.media.ad.db2"); if (mediaDb.exists()) { mediaDb.delete(); } } // Recommend the user to do a full-sync if they're upgrading from before 2.3.1beta8 if (previous < 20301208) { mRecommendFullSync = true; } // Check if preference upgrade or database check required, otherwise go to new feature screen int upgradePrefsVersion = AnkiDroidApp.CHECK_PREFERENCES_AT_VERSION; int upgradeDbVersion = AnkiDroidApp.CHECK_DB_AT_VERSION; if (previous < upgradeDbVersion || previous < upgradePrefsVersion) { if (previous < upgradePrefsVersion && current >= upgradePrefsVersion) { Timber.d("Upgrading preferences"); CompatHelper.removeHiddenPreferences(this.getApplicationContext()); upgradePreferences(previous); } // Integrity check loads asynchronously and then restart deckpicker when finished if (previous < upgradeDbVersion && current >= upgradeDbVersion) { integrityCheck(); } else if (previous < upgradePrefsVersion && current >= upgradePrefsVersion) { // If integrityCheck() doesn't occur, but we did update preferences we should restart DeckPicker to // proceed restartActivity(); } } else { // If no changes are required we go to the new features activity // There the "lastVersion" is set, so that this code is not reached again if (VersionUtils.isReleaseVersion()) { Intent infoIntent = new Intent(this, Info.class); infoIntent.putExtra(Info.TYPE_EXTRA, Info.TYPE_NEW_VERSION); if (skip != 0) { startActivityForResultWithAnimation(infoIntent, SHOW_INFO_NEW_VERSION, ActivityTransitionAnimation.LEFT); } else { startActivityForResultWithoutAnimation(infoIntent, SHOW_INFO_NEW_VERSION); } } else { // Don't show new features dialog for development builds preferences.edit().putString("lastVersion", VersionUtils.getPkgVersionName()).apply(); String ver = getResources().getString(R.string.updated_version, VersionUtils.getPkgVersionName()); showSnackbar(ver, true, -1, null, findViewById(R.id.root_layout), null); showStartupScreensAndDialogs(preferences, 2); } } } else { // This is the main call when there is nothing special required onFinishedStartup(); } }
From source file:com.nit.vicky.Reviewer.java
private SharedPreferences restorePreferences() { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); mPrefHideDueCount = preferences.getBoolean("hideDueCount", false); mPrefWhiteboard = preferences.getBoolean("whiteboard", false); mPrefWriteAnswers = preferences.getBoolean("writeAnswers", true); mPrefTextSelection = preferences.getBoolean("textSelection", true); mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false); // mDeckFilename = preferences.getString("deckFilename", ""); mNightMode = preferences.getBoolean("invertedColors", false); mInvertedColors = mNightMode;/*w w w. jav a2s . c o m*/ mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true); mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false); mZoomEnabled = preferences.getBoolean("zoom", false); mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO); mRelativeImageSize = preferences.getInt("relativeImageSize", 100); mRelativeButtonSize = preferences.getInt("answerButtonSize", 100); mInputWorkaround = preferences.getBoolean("inputWorkaround", false); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); mPrefForceQuickUpdate = preferences.getBoolean("forceQuickUpdate", true); mSpeakText = preferences.getBoolean("tts", false); mShowProgressBars = preferences.getBoolean("progressBars", true); mPrefFadeScrollbars = preferences.getBoolean("fadeScrollbars", false); mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false); mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20); mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60); mScrollingButtons = preferences.getBoolean("scrolling_buttons", false); mDoubleScrolling = preferences.getBoolean("double_scrolling", false); mPrefCenterVertically = preferences.getBoolean("centerVertically", false); mGesturesEnabled = AnkiDroidApp.initiateGestures(this, preferences); if (mGesturesEnabled) { mGestureShake = Integer.parseInt(preferences.getString("gestureShake", "0")); if (mGestureShake != 0) { mShakeEnabled = true; } mShakeIntensity = preferences.getInt("minShakeIntensity", 70); mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9")); mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0")); mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8")); mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17")); mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7")); mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3")); mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6")); mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12")); mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2")); mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11")); } if (mPrefTextSelection && mLongClickWorkaround) { mGestureLongclick = GESTURE_LOOKUP; } mShowAnimations = preferences.getBoolean("themeAnimations", false); if (mShowAnimations) { int animationDuration = preferences.getInt("animationDuration", 500); mAnimationDurationTurn = animationDuration; mAnimationDurationMove = animationDuration; } // allow screen orientation in reviewer only when fix preference is not set if (preferences.getBoolean("fixOrientation", false)) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } if (preferences.getBoolean("keepScreenOn", false)) { this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } mSimpleInterface = preferences.getBoolean("simpleInterface", false); if (mSimpleInterface) { String tags = preferences.getString("simpleInterfaceExcludeTags", "").replace(",", " "); mSimpleInterfaceExcludeTags = new ArrayList<String>(); for (String t : tags.split(" ")) { if (t.length() > 0) { mSimpleInterfaceExcludeTags.add(t); } } } // These are preferences we pull out of the collection instead of SharedPreferences try { mShowNextReviewTime = AnkiDroidApp.getCol().getConf().getBoolean("estTimes"); mShowRemainingCardCount = AnkiDroidApp.getCol().getConf().getBoolean("dueCounts"); } catch (JSONException e) { throw new RuntimeException(); } return preferences; }
From source file:com.hichinaschool.flashcards.anki.Reviewer.java
private SharedPreferences restorePreferences() { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); mPrefHideDueCount = preferences.getBoolean("hideDueCount", false); mPrefWhiteboard = preferences.getBoolean("whiteboard", false); mPrefWriteAnswers = preferences.getBoolean("writeAnswers", true); mPrefTextSelection = preferences.getBoolean("textSelection", true); mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false); // mDeckFilename = preferences.getString("deckFilename", ""); mNightMode = preferences.getBoolean("invertedColors", false); mInvertedColors = mNightMode;/*from w w w .j a va 2s . c o m*/ mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true); mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false); mZoomEnabled = preferences.getBoolean("zoom", false); mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO); mRelativeImageSize = preferences.getInt("relativeImageSize", 100); mRelativeButtonSize = preferences.getInt("answerButtonSize", 100); mInputWorkaround = preferences.getBoolean("inputWorkaround", false); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); mPrefForceQuickUpdate = preferences.getBoolean("forceQuickUpdate", false); mSpeakText = preferences.getBoolean("tts", false); mShowProgressBars = preferences.getBoolean("progressBars", true); mPrefFadeScrollbars = preferences.getBoolean("fadeScrollbars", false); mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false); mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20); mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60); mScrollingButtons = preferences.getBoolean("scrolling_buttons", false); mDoubleScrolling = preferences.getBoolean("double_scrolling", false); mPrefCenterVertically = preferences.getBoolean("centerVertically", false); mGesturesEnabled = AnkiDroidApp.initiateGestures(this, preferences); if (mGesturesEnabled) { mGestureShake = Integer.parseInt(preferences.getString("gestureShake", "0")); if (mGestureShake != 0) { mShakeEnabled = true; } mShakeIntensity = preferences.getInt("minShakeIntensity", 70); mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9")); mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0")); mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8")); mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17")); mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7")); mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3")); mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6")); mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12")); mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2")); mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11")); } if (mPrefTextSelection && mLongClickWorkaround) { mGestureLongclick = GESTURE_LOOKUP; } mShowAnimations = preferences.getBoolean("themeAnimations", false); if (mShowAnimations) { int animationDuration = preferences.getInt("animationDuration", 500); mAnimationDurationTurn = animationDuration; mAnimationDurationMove = animationDuration; } // allow screen orientation in reviewer only when fix preference is not set if (preferences.getBoolean("fixOrientation", false)) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } if (preferences.getBoolean("keepScreenOn", false)) { this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } mSimpleInterface = preferences.getBoolean("simpleInterface", false); if (mSimpleInterface) { String tags = preferences.getString("simpleInterfaceExcludeTags", "").replace(",", " "); mSimpleInterfaceExcludeTags = new ArrayList<String>(); for (String t : tags.split(" ")) { if (t.length() > 0) { mSimpleInterfaceExcludeTags.add(t); } } } // These are preferences we pull out of the collection instead of SharedPreferences try { mShowNextReviewTime = AnkiDroidApp.getCol().getConf().getBoolean("estTimes"); mShowRemainingCardCount = AnkiDroidApp.getCol().getConf().getBoolean("dueCounts"); } catch (JSONException e) { throw new RuntimeException(); } return preferences; }
From source file:com.ichi2.anki2.Reviewer.java
private SharedPreferences restorePreferences() { SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); mPrefHideDueCount = preferences.getBoolean("hideDueCount", false); mPrefWhiteboard = preferences.getBoolean("whiteboard", false); mPrefRecord = preferences.getBoolean("record", false); mPrefWriteAnswers = preferences.getBoolean("writeAnswers", true); mPrefTextSelection = preferences.getBoolean("textSelection", true); mLongClickWorkaround = preferences.getBoolean("textSelectionLongclickWorkaround", false); // mDeckFilename = preferences.getString("deckFilename", ""); mNightMode = preferences.getBoolean("invertedColors", false); mInvertedColors = mNightMode;/*from w ww .j a v a 2 s. com*/ mBlackWhiteboard = preferences.getBoolean("blackWhiteboard", true); mPrefFullscreenReview = preferences.getBoolean("fullscreenReview", false); mshowNextReviewTime = preferences.getBoolean("showNextReviewTime", true); mZoomEnabled = preferences.getBoolean("zoom", false); mDisplayFontSize = preferences.getInt("relativeDisplayFontSize", 100);// Card.DEFAULT_FONT_SIZE_RATIO); mRelativeButtonSize = preferences.getInt("answerButtonSize", 100); mInputWorkaround = preferences.getBoolean("inputWorkaround", false); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); mSpeakText = preferences.getBoolean("tts", false); mShowProgressBars = preferences.getBoolean("progressBars", true); mPrefFadeScrollbars = preferences.getBoolean("fadeScrollbars", false); mPrefUseTimer = preferences.getBoolean("timeoutAnswer", false); mWaitAnswerSecond = preferences.getInt("timeoutAnswerSeconds", 20); mWaitQuestionSecond = preferences.getInt("timeoutQuestionSeconds", 60); mScrollingButtons = preferences.getBoolean("scrolling_buttons", false); mDoubleScrolling = preferences.getBoolean("double_scrolling", false); mGesturesEnabled = AnkiDroidApp.initiateGestures(this, preferences); if (mGesturesEnabled) { mGestureShake = Integer.parseInt(preferences.getString("gestureShake", "0")); if (mGestureShake != 0) { mShakeEnabled = true; } mShakeIntensity = preferences.getInt("minShakeIntensity", 70); mGestureSwipeUp = Integer.parseInt(preferences.getString("gestureSwipeUp", "9")); mGestureSwipeDown = Integer.parseInt(preferences.getString("gestureSwipeDown", "0")); mGestureSwipeLeft = Integer.parseInt(preferences.getString("gestureSwipeLeft", "8")); mGestureSwipeRight = Integer.parseInt(preferences.getString("gestureSwipeRight", "17")); mGestureDoubleTap = Integer.parseInt(preferences.getString("gestureDoubleTap", "7")); mGestureTapLeft = Integer.parseInt(preferences.getString("gestureTapLeft", "3")); mGestureTapRight = Integer.parseInt(preferences.getString("gestureTapRight", "6")); mGestureTapTop = Integer.parseInt(preferences.getString("gestureTapTop", "12")); mGestureTapBottom = Integer.parseInt(preferences.getString("gestureTapBottom", "2")); mGestureLongclick = Integer.parseInt(preferences.getString("gestureLongclick", "11")); } if (mPrefTextSelection && mLongClickWorkaround) { mGestureLongclick = GESTURE_LOOKUP; } mShowAnimations = preferences.getBoolean("themeAnimations", false); if (mShowAnimations) { int animationDuration = preferences.getInt("animationDuration", 500); mAnimationDurationTurn = animationDuration; mAnimationDurationMove = animationDuration; } // allow screen orientation in reviewer only when fix preference is not set if (preferences.getBoolean("fixOrientation", false)) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } if (preferences.getBoolean("keepScreenOn", false)) { this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } mSimpleInterface = preferences.getBoolean("simpleInterface", false); if (mSimpleInterface) { String tags = preferences.getString("simpleInterfaceExcludeTags", "").replace(",", " "); mSimpleInterfaceExcludeTags = new ArrayList<String>(); for (String t : tags.split(" ")) { if (t.length() > 0) { mSimpleInterfaceExcludeTags.add(t); } } } return preferences; }
From source file:org.telegram.android.MessagesController.java
public boolean isDialogMuted(long dialog_id) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);//from ww w .j av a2s .co m int mute_type = preferences.getInt("notify2_" + dialog_id, 0); if (mute_type == 2) { return true; } else if (mute_type == 3) { int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { return true; } } return false; }
From source file:cm.aptoide.pt.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { AptoideThemePicker.setAptoideTheme(this); super.onCreate(savedInstanceState); serviceDownloadManagerIntent = new Intent(this, ServiceDownloadManager.class); startService(serviceDownloadManagerIntent); mContext = this; File sdcard_file = new File(SDCARD); if (!sdcard_file.exists() || !sdcard_file.canWrite()) { View simpleView = LayoutInflater.from(mContext).inflate(R.layout.dialog_simple_layout, null); Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(simpleView); final AlertDialog noSDDialog = dialogBuilder.create(); noSDDialog.setTitle(getText(R.string.remote_in_noSD_title)); noSDDialog.setIcon(android.R.drawable.ic_dialog_alert); TextView message = (TextView) simpleView.findViewById(R.id.dialog_message); message.setText(getText(R.string.remote_in_noSD)); noSDDialog.setCancelable(false); noSDDialog.setButton(Dialog.BUTTON_NEUTRAL, getString(android.R.string.ok), new Dialog.OnClickListener() { @Override//w w w . j a va 2 s . co m public void onClick(DialogInterface arg0, int arg1) { finish(); } }); noSDDialog.show(); } else { StatFs stat = new StatFs(sdcard_file.getPath()); long blockSize = stat.getBlockSize(); long totalBlocks = stat.getBlockCount(); long availableBlocks = stat.getAvailableBlocks(); long total = (blockSize * totalBlocks) / 1024 / 1024; long avail = (blockSize * availableBlocks) / 1024 / 1024; Log.d("Aptoide", "* * * * * * * * * *"); Log.d("Aptoide", "Total: " + total + " Mb"); Log.d("Aptoide", "Available: " + avail + " Mb"); if (avail < 10) { Log.d("Aptoide", "No space left on SDCARD..."); Log.d("Aptoide", "* * * * * * * * * *"); View simpleView = LayoutInflater.from(this).inflate(R.layout.dialog_simple_layout, null); Builder dialogBuilder = new AlertDialog.Builder(this).setView(simpleView); final AlertDialog noSpaceDialog = dialogBuilder.create(); noSpaceDialog.setIcon(android.R.drawable.ic_dialog_alert); TextView message = (TextView) simpleView.findViewById(R.id.dialog_message); message.setText(getText(R.string.remote_in_noSDspace)); noSpaceDialog.setButton(Dialog.BUTTON_NEUTRAL, getText(android.R.string.ok), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { finish(); } }); noSpaceDialog.show(); } else { SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(mContext); editor = PreferenceManager.getDefaultSharedPreferences(mContext).edit(); if (!sPref.contains("matureChkBox")) { editor.putBoolean("matureChkBox", ApplicationAptoide.MATURECONTENTSWITCHVALUE); SharedPreferences sPrefOld = getSharedPreferences("aptoide_prefs", MODE_PRIVATE); if (sPrefOld.getString("app_rating", "none").equals("Mature")) { editor.putBoolean("matureChkBox", false); } } if (!sPref.contains("version")) { ApplicationAptoide.setRestartLauncher(true); try { editor.putInt("version", getPackageManager().getPackageInfo(getPackageName(), 0).versionCode); } catch (NameNotFoundException e) { e.printStackTrace(); } } if (sPref.getString("myId", null) == null) { String rand_id = UUID.randomUUID().toString(); editor.putString("myId", rand_id); } if (sPref.getInt("scW", 0) == 0 || sPref.getInt("scH", 0) == 0) { DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); editor.putInt("scW", dm.widthPixels); editor.putInt("scH", dm.heightPixels); } editor.commit(); File file = new File(LOCAL_PATH + "/apks"); if (!file.exists()) { file.mkdirs(); } new Thread(new Runnable() { @Override public void run() { // Note the L that tells the compiler to interpret the // number as a Long final long MAXFILEAGE = 2678400000L; // 1 month in // milliseconds // Get file handle to the directory. In this case the // application files dir File dir = new File(LOCAL_PATH + "/apks"); // Optain list of files in the directory. // listFiles() returns a list of File objects to each // file found. File[] files = dir.listFiles(); // Loop through all files for (File f : files) { // Get the last modified date. Miliseconds since // 1970 long lastmodified = f.lastModified(); // Do stuff here to deal with the file.. // For instance delete files older than 1 month if (lastmodified + MAXFILEAGE < System.currentTimeMillis()) { f.delete(); } } } }).start(); db = Database.getInstance(); Intent i = new Intent(mContext, MainService.class); startService(i); bindService(i, conn, Context.BIND_AUTO_CREATE); order = Order.values()[PreferenceManager.getDefaultSharedPreferences(mContext).getInt("order_list", 0)]; registerReceiver(updatesReceiver, new IntentFilter("update")); registerReceiver(statusReceiver, new IntentFilter("status")); registerReceiver(loginReceiver, new IntentFilter("login")); registerReceiver(storePasswordReceiver, new IntentFilter("401")); registerReceiver(redrawInstalledReceiver, new IntentFilter("pt.caixamagica.aptoide.REDRAW")); if (!ApplicationAptoide.MULTIPLESTORES) { registerReceiver(parseFailedReceiver, new IntentFilter("PARSE_FAILED")); } registerReceiver(newRepoReceiver, new IntentFilter("pt.caixamagica.aptoide.NEWREPO")); registered = true; categoriesStrings = new HashMap<String, Integer>(); // categoriesStrings.put("Applications", R.string.applications); boolean serversFileIsEmpty = true; if (sPref.getBoolean("firstrun", true)) { // Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); // shortcutIntent.setClassName("cm.aptoide.pt", // "cm.aptoide.pt.Start"); // final Intent intent = new Intent(); // intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, // shortcutIntent); // // intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, // getString(R.string.app_name)); // Parcelable iconResource = // Intent.ShortcutIconResource.fromContext(this, // R.drawable.ic_launcher); // // intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, // iconResource); // intent.putExtra("duplicate", false); // intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); // sendBroadcast(intent); if (new File(LOCAL_PATH + "/servers.xml").exists() && ApplicationAptoide.DEFAULTSTORENAME == null) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); MyappHandler handler = new MyappHandler(); sp.parse(new File(LOCAL_PATH + "/servers.xml"), handler); ArrayList<String> server = handler.getServers(); if (server.isEmpty()) { serversFileIsEmpty = true; } else { getIntent().putExtra("newrepo", server); } } catch (Exception e) { e.printStackTrace(); } } editor.putBoolean("firstrun", false); editor.putBoolean("orderByCategory", true); editor.commit(); } if (getIntent().hasExtra("newrepo")) { ArrayList<String> repos = (ArrayList<String>) getIntent().getSerializableExtra("newrepo"); for (final String uri2 : repos) { View simpleView = LayoutInflater.from(mContext).inflate(R.layout.dialog_simple_layout, null); Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(simpleView); final AlertDialog addNewRepoDialog = dialogBuilder.create(); addNewRepoDialog.setTitle(getString(R.string.add_store)); addNewRepoDialog.setIcon(android.R.drawable.ic_menu_add); TextView message = (TextView) simpleView.findViewById(R.id.dialog_message); message.setText((getString(R.string.newrepo_alrt) + uri2 + " ?")); addNewRepoDialog.setCancelable(false); addNewRepoDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogAddStore(uri2, null, null); } }); addNewRepoDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.cancel(); } }); addNewRepoDialog.show(); } } else if (db.getStores(false).getCount() == 0 && ApplicationAptoide.DEFAULTSTORENAME == null && serversFileIsEmpty) { View simpleView = LayoutInflater.from(mContext).inflate(R.layout.dialog_simple_layout, null); Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(simpleView); final AlertDialog addAppsRepoDialog = dialogBuilder.create(); addAppsRepoDialog.setTitle(getString(R.string.add_store)); addAppsRepoDialog.setIcon(android.R.drawable.ic_menu_add); TextView message = (TextView) simpleView.findViewById(R.id.dialog_message); message.setText(getString(R.string.myrepo_alrt) + "\n" + "http://apps.store.aptoide.com/"); addAppsRepoDialog.setCancelable(false); addAppsRepoDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogAddStore("http://apps.store.aptoide.com", null, null); } }); addAppsRepoDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.cancel(); } }); addAppsRepoDialog.show(); } new Thread(new Runnable() { @Override public void run() { try { getUpdateParameters(); if (getPackageManager().getPackageInfo(getPackageName(), 0).versionCode < Integer .parseInt(updateParams.get("versionCode"))) { runOnUiThread(new Runnable() { @Override public void run() { requestUpdateSelf(); } }); } } catch (Exception e) { e.printStackTrace(); } } }).start(); } featuredView = LayoutInflater.from(mContext).inflate(R.layout.page_featured, null); availableView = LayoutInflater.from(mContext).inflate(R.layout.page_available, null); updateView = LayoutInflater.from(mContext).inflate(R.layout.page_updates, null); banner = (LinearLayout) availableView.findViewById(R.id.banner); breadcrumbs = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.breadcrumb_container, null); installedView = new ListView(mContext); updatesListView = (ListView) updateView.findViewById(R.id.updates_list); availableListView = (ListView) availableView.findViewById(R.id.available_list); joinStores = (CheckBox) availableView.findViewById(R.id.join_stores); availableAdapter = new AvailableListAdapter(mContext, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); installedAdapter = new InstalledAdapter(mContext, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER, db); updatesAdapter = new UpdatesAdapter(mContext, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER); pb = (TextView) availableView.findViewById(R.id.loading_pb); addStoreButton = availableView.findViewById(R.id.add_store); bannerStoreAvatar = (ImageView) banner.findViewById(R.id.banner_store_avatar); bannerStoreName = (TextView) banner.findViewById(R.id.banner_store_name); bannerStoreDescription = (AutoScaleTextView) banner.findViewById(R.id.banner_store_description); } }
From source file:org.telegram.android.MessagesController.java
public MessagesController() { ImageLoader.getInstance();/*from w ww .java2s. com*/ MessagesStorage.getInstance(); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidUpload); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailUpload); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad); NotificationCenter.getInstance().addObserver(this, NotificationCenter.messageReceivedByServer); addSupportUser(); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); enableJoined = preferences.getBoolean("EnableContactJoined", true); preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); maxGroupCount = preferences.getInt("maxGroupCount", 200); maxBroadcastCount = preferences.getInt("maxBroadcastCount", 100); groupBigSize = preferences.getInt("groupBigSize", 10); fontSize = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16); String disabledFeaturesString = preferences.getString("disabledFeatures", null); if (disabledFeaturesString != null && disabledFeaturesString.length() != 0) { try { byte[] bytes = Base64.decode(disabledFeaturesString, Base64.DEFAULT); if (bytes != null) { SerializedData data = new SerializedData(bytes); int count = data.readInt32(false); for (int a = 0; a < count; a++) { TLRPC.TL_disabledFeature feature = TLRPC.TL_disabledFeature.TLdeserialize(data, data.readInt32(false), false); if (feature != null && feature.feature != null && feature.description != null) { disabledFeatures.add(feature); } } } } catch (Exception e) { FileLog.e("tmessages", e); } } }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
public void getSettingShared() { SharedPreferences mSharedPrefs = getSharedPreferences("mysettings", Context.MODE_PRIVATE); final Dialog settingdialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); settingdialog.requestWindowFeature(Window.FEATURE_NO_TITLE); settingdialog.setContentView(R.layout.settingdialoglayout); final SeekBar powerseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Powerbar); final SeekBar engineseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Enginebar); final SeekBar exteriorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Exteriorbar); final SeekBar interiorseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Interiorbar); final SeekBar documentseekbar = (SeekBar) settingdialog.getWindow().findViewById(R.id.Documentbar); // seekbar.putInt("Powerbar", powerseekbarValue).commit(); // powerseekbar.setProgress(4); // Log.i("seek", "setProgress(4)"); engineseekbar.setProgress(mSharedPrefs.getInt("Enginebar", 0)); exteriorseekbar.setProgress(mSharedPrefs.getInt("Exteriorbar", 0)); interiorseekbar.setProgress(mSharedPrefs.getInt("Interiorbar", 0)); documentseekbar.setProgress(mSharedPrefs.getInt("Documentbar", 0)); }