Java Code Examples for com.pixplicity.easyprefs.library.Prefs#getString()

The following examples show how to use com.pixplicity.easyprefs.library.Prefs#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Category.java    From uPods-android with Apache License 2.0 6 votes vote down vote up
/**
 * Call it in application launch to put podcasts categories into the memory
 */
public static void initPodcastsCatrgories() {
    String categoriesJsonStr = Prefs.getString(CATEGORIES_PREF, null);
    if (categoriesJsonStr == null) {
        BackendManager.getInstance().sendRequest(ServerApi.PODCAST_CATEGORIES, new IRequestCallback() {
            @Override
            public void onRequestSuccessed(JSONObject jResponse) {
                try {
                    JSONArray result = jResponse.getJSONArray("result");
                    Prefs.putString(CATEGORIES_PREF, result.toString());
                    Logger.printInfo(CATEGORIES_LOG, "Got " + String.valueOf(result.length()) + " podcasts categories from server");
                } catch (JSONException e) {
                    Logger.printInfo(CATEGORIES_LOG, "Can't get podcasts categories from server");
                    e.printStackTrace();
                }
            }

            @Override
            public void onRequestFailed() {

            }
        });
    }
}
 
Example 2
Source File: SettingsManager.java    From uPods-android with Apache License 2.0 6 votes vote down vote up
private JSONObject readSettings() {
    try {
        if (Prefs.getString(JS_SETTINGS, null) == null) {
            JSONObject settingsObject = new JSONObject();
            settingsObject.put(JS_START_SCREEN, DEFAULT_START_SCREEN);
            settingsObject.put(JS_NOTIFY_EPISODES, DEFAULT_NOTIFY_EPISODS);
            settingsObject.put(JS_PODCASTS_UPDATE_TIME, DEFAULT_PODCAST_UPDATE_TIME);
            settingsObject.put(JS_STREAM_QUALITY, DEFAULT_STREAM_QUALITY);
            settingsObject.put(JS_TOPS_LANGUAGE, Locale.getDefault().getLanguage());

            Prefs.putString(JS_TOPS_LANGUAGE, Locale.getDefault().getLanguage());
            Prefs.putString(JS_SETTINGS, settingsObject.toString());
        }
        return new JSONObject(Prefs.getString(JS_SETTINGS, null));
    } catch (JSONException e) {
        Logger.printInfo(TAG, "Can't read settings");
        e.printStackTrace();
    }
    return null;
}
 
Example 3
Source File: ConfigurationManagerImpl.java    From mirror with Apache License 2.0 5 votes vote down vote up
@Override
public String getString(String preferenceKey, String defaultValue) {
    try {
        return Prefs.getString(preferenceKey, defaultValue);
    } catch (ClassCastException e) {
        Timber.e(e, "Error getting the value for %s", preferenceKey);
        Prefs.remove(preferenceKey);
        return defaultValue;
    }
}
 
Example 4
Source File: LoginMaster.java    From uPods-android with Apache License 2.0 5 votes vote down vote up
public String getLoginType() {
    if (Prefs.getString(SyncMaster.GLOBAL_TOKEN, null) != null) {
        return SyncMaster.TYPE_GLOBAL;
    } else if (AccessToken.getCurrentAccessToken() != null)
        return SyncMaster.TYPE_FB;
    else if (Twitter.getSessionManager().getActiveSession() != null) {
        return SyncMaster.TYPE_TWITTER;
    } else
        return SyncMaster.TYPE_VK;
}
 
Example 5
Source File: LoginMaster.java    From uPods-android with Apache License 2.0 5 votes vote down vote up
public String getToken() {
    if (Prefs.getString(SyncMaster.GLOBAL_TOKEN, null) != null) {
        return Prefs.getString(SyncMaster.GLOBAL_TOKEN, null);
    } else if (AccessToken.getCurrentAccessToken() != null)
        return AccessToken.getCurrentAccessToken().getToken();
    else if (Twitter.getSessionManager().getActiveSession() != null) {
        TwitterSession session = Twitter.getSessionManager().getActiveSession();
        TwitterAuthToken authToken = session.getAuthToken();
        return authToken.token;
    } else
        return VKAccessToken.currentToken().accessToken;
}
 
Example 6
Source File: SettingsManager.java    From uPods-android with Apache License 2.0 5 votes vote down vote up
public void initSettingsFromPreferences() {
    putSettingsValue(JS_NOTIFY_EPISODES, Prefs.getBoolean(JS_NOTIFY_EPISODES, DEFAULT_NOTIFY_EPISODS));
    putSettingsValue(JS_START_SCREEN, Prefs.getString(JS_START_SCREEN, DEFAULT_START_SCREEN));
    putSettingsValue(JS_STREAM_QUALITY, Prefs.getString(JS_STREAM_QUALITY, DEFAULT_STREAM_QUALITY));
    putSettingsValue(JS_TOPS_LANGUAGE, Prefs.getString(JS_TOPS_LANGUAGE, Locale.getDefault().getLanguage()));

    String pUpdateTime = Prefs.getString(JS_PODCASTS_UPDATE_TIME, String.valueOf(DEFAULT_PODCAST_UPDATE_TIME));
    putSettingsValue(JS_PODCASTS_UPDATE_TIME, Integer.valueOf(pUpdateTime));
}
 
Example 7
Source File: Detail.java    From faveo-helpdesk-android-app with Open Software License 3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
    setUpViews(rootView);
    animation= AnimationUtils.loadAnimation(getActivity(),R.anim.shake_error);
    progressDialog = new ProgressDialog(getContext());
    progressDialog.setMessage(getString(R.string.fetching_detail));
    // progressDialog.show();
    if (InternetReceiver.isConnected()) {
        task = new FetchTicketDetail(Prefs.getString("TICKETid",null));
        task.execute();
    }
    return rootView;
}
 
Example 8
Source File: MainActivity.java    From EasyPrefs with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    // get the saved String from the preference by key, and give a default value
    // if Prefs does not contain the key.
    String s = Prefs.getString(SAVED_TEXT, getString(R.string.not_found));
    double d = Prefs.getDouble(SAVED_NUMBER, -1.0);
    updateText(s);
    updateNumber(d, false);
}
 
Example 9
Source File: PreferenceManagerImpl.java    From mirror with Apache License 2.0 4 votes vote down vote up
public String getUserName() {
    return Prefs.getString(PREFERENCE_USER_NAME, "User");
}
 
Example 10
Source File: Category.java    From uPods-android with Apache License 2.0 4 votes vote down vote up
public static List<Category> getPodcastsCategoriesList() {
    String categoriesJsonStr = Prefs.getString(CATEGORIES_PREF, null);
    return getCategoriesListFromJSON(categoriesJsonStr);
}
 
Example 11
Source File: ClientDetailActivity.java    From faveo-helpdesk-android-app with Open Software License 3.0 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_client_profile);
        Window window = ClientDetailActivity.this.getWindow();

        // clear FLAG_TRANSLUCENT_STATUS flag:
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

// finally change the color
        window.setStatusBarColor(ContextCompat.getColor(ClientDetailActivity.this,R.color.faveo));
        ButterKnife.bind(this);
        Constants.URL = Prefs.getString("COMPANY_URL", "");
        Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
//        if (getSupportActionBar() != null) {
//            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//            getSupportActionBar().setDisplayShowHomeEnabled(true);
//            getSupportActionBar().setDisplayShowTitleEnabled(false);
//        }
        TextView mTitle = (TextView) mToolbar.findViewById(R.id.title);
        mTitle.setText(R.string.profile);
        imageViewBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        setUpViews();
        Intent intent = getIntent();
        clientID = intent.getStringExtra("CLIENT_ID");

        if (InternetReceiver.isConnected()) {
            progressDialog.show();
            task = new FetchClientTickets(ClientDetailActivity.this);
            task.execute();


        } else Toasty.warning(this, getString(R.string.oops_no_internet), Toast.LENGTH_LONG).show();

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
        setupViewPager();
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setOnTabSelectedListener(onTabSelectedListener);

    }
 
Example 12
Source File: InternalNoteActivity.java    From faveo-helpdesk-android-app with Open Software License 3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_internal_note);
    overridePendingTransition(R.anim.slide_in_from_right,R.anim.slide_in_from_right);
    Window window = InternalNoteActivity.this.getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(ContextCompat.getColor(InternalNoteActivity.this,R.color.faveo));
    toolbar= (Toolbar) findViewById(R.id.toolbarForInternalNote);
    imageView= (ImageView) toolbar.findViewById(R.id.imageViewBackTicketInternalNote);
    editTextInternalNote = (EditText) findViewById(R.id.editText_internal_note);
    buttonCreate = (Button) findViewById(R.id.button_create);
    ticketID= Prefs.getString("TICKETid",null);
    progressDialog=new ProgressDialog(this);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    buttonCreate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String note = editTextInternalNote.getText().toString();
            if (note.trim().length() == 0) {
                Toasty.warning(InternalNoteActivity.this, getString(R.string.msg_must_not_be_empty), Toast.LENGTH_LONG).show();
                return;
            }
            String userID = Prefs.getString("ID", null);
            if (userID != null && userID.length() != 0) {
                try {
                    note = URLEncoder.encode(note, "utf-8");
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }

                new CreateInternalNoteForTicket(Integer.parseInt(ticketID), Integer.parseInt(userID), note).execute();
                progressDialog.setMessage(getString(R.string.creating_note));
                progressDialog.show();


            } else
                Toasty.warning(InternalNoteActivity.this, getString(R.string.wrong_user_id), Toast.LENGTH_LONG).show();
        }
    });
    }
 
Example 13
Source File: LoginActivity.java    From faveo-helpdesk-android-app with Open Software License 3.0 4 votes vote down vote up
protected void onPostExecute(String result) {
            progressDialogVerifyURL.dismiss();
            if (result == null) {
                count++;
//                if (count==0){
//                    Toasty.warning(context, getString(R.string.invalid_url), Toast.LENGTH_LONG).show();
//                    count--;
//                    return;
//                }
                if (result == null) {
                    count++;
                    //progressBar.setVisibility(View.GONE);
                    buttonVerifyURL.setEnabled(true);
                    Toasty.warning(context, getString(R.string.invalid_url), Toast.LENGTH_LONG).show();
                    return;
                }

                //new VerifyURLSecure(LoginActivity.this,companyURL1).execute();
                return;
            }
                //String status=jsonObject.getString("status");
              else  if (result.contains("success")){
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
                        dynamicShortcut();
                    }
                    Prefs.putString("BASE_URL", baseURL);
                    Log.d("BASEurl",baseURL);
                    Prefs.putString("COMPANY_URL", companyURL + "api/v1/");
                    Constants.URL = Prefs.getString("COMPANY_URL", "");
                    if (BuildConfig.DEBUG) {
                        viewflipper.showNext();
                        imageBackButton.setVisibility(View.VISIBLE);
                        url.setText(baseURL);
                        url.setVisibility(View.VISIBLE);
                        flipColor.setBackgroundColor(ContextCompat.getColor(LoginActivity.this, R.color.faveo));
                    } else {
                        viewflipper.showNext();
                        imageBackButton.setVisibility(View.VISIBLE);
                        url.setText(baseURL);
                        url.setVisibility(View.VISIBLE);
                        flipColor.setBackgroundColor(ContextCompat.getColor(context, R.color.faveo));
                    }

                } else {
                    linearLayout.startAnimation(animation);
                    urlError.setVisibility(View.VISIBLE);
                    urlError.setText(getString(R.string.error_verifying_url));
                    urlError.setTextColor(Color.parseColor("#ff0000"));
                    urlError.postDelayed(new Runnable() {
                        public void run() {
                            urlError.setVisibility(View.INVISIBLE);
                        }
                    }, 5000);

                }



            }
 
Example 14
Source File: Helpdesk.java    From faveo-helpdesk-android-app with Open Software License 3.0 4 votes vote down vote up
public Helpdesk() {
    apiKey = Constants.API_KEY;
    token = Prefs.getString("TOKEN", "");
    //token = Preference.getToken();
    IP = null;
}
 
Example 15
Source File: Authenticate.java    From faveo-helpdesk-android-app with Open Software License 3.0 4 votes vote down vote up
public Authenticate() {
    apiKey = Constants.API_KEY;
    token = Prefs.getString("TOKEN", "");
    IP = null;
}