Android Open Source - Android_ApplicationTemplate Preferences






From Project

Back to project page Android_ApplicationTemplate.

License

The source code is released under:

MIT License

If you think the Android project Android_ApplicationTemplate listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*The MIT License (MIT)
/*  w w w .j av  a  2  s  . c  o  m*/
Copyright (c) 2014 Ahmad Barqawi (github.com/Barqawiz)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
package com.iaraby.template.data;

import com.company.appname.R;
import com.iaraby.utility.LogManager;

import android.content.Context;
import android.content.res.Resources.NotFoundException;

/**
 * One instance to manage the application preferences 
 * 
 * This class connected to res > values > config.xml, make sure to take a look to config.xml and change the fields
 * based on your case
 *
 */
public class Preferences {

  private static Preferences instance;

  private Context context;
  
  public static Preferences getInstance(Context context) {
    if (instance == null)
      instance = new Preferences(context);
    return instance;
  } //Method: manage instance
  
  private Preferences(Context context) {
    this.context = context;
  } //Constructor
  
  public boolean isRTL() {
    boolean isRigthToLeft = false;
    try {
      isRigthToLeft = context.getResources().getBoolean(R.bool.is_right_to_left);
    } catch(NotFoundException ex){
      LogManager.getIns().ee(Constants.LOG_TAG, "Error to get is_right_to_left from config.xml");
    } catch (Exception e) {
      LogManager.getIns().ee(Constants.LOG_TAG, "Error to get is_right_to_left from config.xml");
    }
    return isRigthToLeft;
  } //method: is right to left
  
  public String getMarketLink() {
    //if you want to change the more link functionality so it does not direct to Google play
    // but to web-site link for example comment the below link and return the link directly
    return Constants.MARKET_LINK + context.getString(R.string.google_play_developer_name);
  }
  
  public int getDatabaseVersion() {
    return context.getResources().getInteger(R.integer.db_version);
  }
  
  public String getAdmobBannerId() {
    //banner_id accessed  also through fragment_details.xml layout
    return context.getString(R.string.banner_id);
  }
  public String getAdmobInterstitialId() {
    return context.getString(R.string.interstitial_Id);
  }
  
} //Class





Java Source Code List

android.UnusedStub.java
com.iaraby.template.control.DetailsPagerAdapter.java
com.iaraby.template.control.DetailsTask.java
com.iaraby.template.control.FavGarbagCollector.java
com.iaraby.template.data.Beans.java
com.iaraby.template.data.Constants.java
com.iaraby.template.data.FavoriteManager.java
com.iaraby.template.data.MyDataAdapter.java
com.iaraby.template.data.Preferences.java
com.iaraby.template.util.DialogManager.java
com.iaraby.template.util.FontManager.java
com.iaraby.template.view.MainActivity.java
com.iaraby.template.view.Master_Activity.java
com.iaraby.template.view.fragment.DetailsFrag.java
com.iaraby.template.view.fragment.ListFrag.java
com.iaraby.template.view.fragment.MainFragment.java