Added HiddenSettingsActivity
This commit is contained in:
@@ -14,14 +14,19 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme" >
|
android:theme="@style/AppTheme" >
|
||||||
<activity
|
<activity
|
||||||
android:name="com.mhalka.qurantranslationdisplayclient.MainActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name"
|
||||||
|
android:screenOrientation="sensorPortrait" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".HiddenSettingsActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:screenOrientation="sensorPortrait" >
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" >
|
||||||
android:background="@drawable/background" >
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/lbl_letters"
|
android:id="@+id/lbl_letters"
|
||||||
@@ -27,15 +26,24 @@
|
|||||||
<requestFocus />
|
<requestFocus />
|
||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/lbl_timeout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_below="@+id/ed_letters"
|
||||||
|
android:text="@string/set_timeout"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/spin_timeout"
|
android:id="@+id/spin_timeout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_below="@+id/ed_letters"
|
android:layout_below="@+id/lbl_timeout"
|
||||||
android:prompt="@string/set_timeout"
|
android:entries="@array/timeout_period" />
|
||||||
android:entries="@string/settings" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_save"
|
android:id="@+id/btn_save"
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.mhalka.qurantranslationdisplayclient;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
public class HiddenSettingsActivity extends Activity {
|
||||||
|
// Set constants for Shared Preferences
|
||||||
|
public static final String PREFS_NAME = "QuranTranslationDisplayClient";
|
||||||
|
public static final String LETTERS_SIZE = "LettersSize";
|
||||||
|
public static final String TIMEOUT_PERIOD = "TimeoutPeriod";
|
||||||
|
|
||||||
|
// Set variables for layout elements
|
||||||
|
private EditText mLetterSize;
|
||||||
|
private Spinner mTimeout;
|
||||||
|
private Button mSave;
|
||||||
|
|
||||||
|
/** Called when the activity is first created. */
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_hidden_settings);
|
||||||
|
|
||||||
|
mLetterSize = (EditText) findViewById(R.id.ed_letters);
|
||||||
|
mTimeout = (Spinner) findViewById(R.id.spin_timeout);
|
||||||
|
mSave = (Button) findViewById(R.id.btn_save);
|
||||||
|
|
||||||
|
// Get Shared Preferences
|
||||||
|
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
|
||||||
|
// Check whether the preferences exist and then set values
|
||||||
|
Boolean mEnteredPrefs = settings.contains(LETTERS_SIZE);
|
||||||
|
|
||||||
|
if (mEnteredPrefs) {
|
||||||
|
String LettersSize = settings.getString(LETTERS_SIZE, "20");
|
||||||
|
Integer TimeoutPeriod = settings.getInt(TIMEOUT_PERIOD, 0);
|
||||||
|
mLetterSize.setText(LettersSize.toString());
|
||||||
|
mTimeout.setSelection(TimeoutPeriod);
|
||||||
|
} else {
|
||||||
|
mLetterSize.setText("20");
|
||||||
|
mTimeout.setSelection(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
mTimeout.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(AdapterView<?> parent, View view,
|
||||||
|
int pos, long id) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected(AdapterView<?> arg0) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mSave.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
// Get Shared Preferences and write new values
|
||||||
|
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
|
||||||
|
SharedPreferences.Editor editor = settings.edit();
|
||||||
|
editor.putString(LETTERS_SIZE, String.valueOf(mLetterSize.getText()));
|
||||||
|
editor.putInt(TIMEOUT_PERIOD, mTimeout.getSelectedItemPosition());
|
||||||
|
editor.commit();
|
||||||
|
|
||||||
|
// Return to the MainActivity
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.mhalka.qurantranslationdisplayclient;
|
package com.mhalka.qurantranslationdisplayclient;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.View.OnLongClickListener;
|
import android.view.View.OnLongClickListener;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
private ImageView mHiddenSettings;
|
private ImageView mHiddenSettings;
|
||||||
@@ -27,9 +27,8 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
// TODO Auto-generated method stub
|
Intent intent = new Intent(MainActivity.this, HiddenSettingsActivity.class);
|
||||||
Toast.makeText(getApplicationContext(), "Aktivirano je skriveno dugme.",
|
startActivity(intent);
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user