Android Open Source - no-cloud-share Settings Activity






From Project

Back to project page no-cloud-share.

License

The source code is released under:

GNU General Public License

If you think the Android project no-cloud-share 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

package de.ub0r.android.nocloudshare;
//w w  w . ja v a2s  .  c  o m
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.text.TextUtils;
import android.view.MenuItem;

import de.ub0r.android.logg0r.Log;

public class SettingsActivity extends PreferenceActivity {

    private static final String TAG = "SettingsActivity";

    public static final String PREFS_PORT = "port";

    public static final String DEFAULT_PORT = "8808";

    private static final String PREFS_EXPIRATION_MINUTES = "expiration";

    private static final String DEFAULT_EXPIRATION_MINUTES = "15";

    public static final String PREFS_SHOW_INDEX = "show_index";

    public static final boolean DEFAULT_SHOW_INDEX = false;

    public static long getExpirationPeriod(final SharedPreferences p) {
        String s = p.getString(PREFS_EXPIRATION_MINUTES, DEFAULT_EXPIRATION_MINUTES);
        if (TextUtils.isEmpty(s)) {
            s = DEFAULT_EXPIRATION_MINUTES;
        }
        long l;
        try {
            l = Long.parseLong(s);
        } catch (NumberFormatException e) {
            Log.d(TAG, "could not parse expiration period: ", s);
            l = Long.parseLong(SettingsActivity.DEFAULT_EXPIRATION_MINUTES);
        }
        return l * 60L * 1000L;
    }

    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //noinspection ConstantConditions
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);

        //noinspection deprecation
        addPreferencesFromResource(R.xml.pref_settings);
    }

    @Override
    public boolean onOptionsItemSelected(final MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
}




Java Source Code List

de.ub0r.android.nocloudshare.AboutActivity.java
de.ub0r.android.nocloudshare.HttpService.java
de.ub0r.android.nocloudshare.IntroActivity.java
de.ub0r.android.nocloudshare.SettingsActivity.java
de.ub0r.android.nocloudshare.ShareActivity.java
de.ub0r.android.nocloudshare.ShareFragment.java
de.ub0r.android.nocloudshare.ShareListActivity.java
de.ub0r.android.nocloudshare.http.BitmapLruCache.java
de.ub0r.android.nocloudshare.http.Httpd.java
de.ub0r.android.nocloudshare.model.GsonFactory.java
de.ub0r.android.nocloudshare.model.ShareItemContainer.java
de.ub0r.android.nocloudshare.model.ShareItem.java
de.ub0r.android.nocloudshare.views.CheckableRelativeLayout.java
de.ub0r.android.nocloudshare.views.MeasuringRelativeLayout.java
fi.iki.elonen.NanoHTTPD.java