Base 1.1
This commit is contained in:
parent
6fd3df16d4
commit
a1081b3cc7
|
@ -25,6 +25,7 @@ dependencies {
|
|||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
compile 'com.android.support:appcompat-v7:26+'
|
||||
compile 'com.android.support:design:26+'
|
||||
compile(name:'colorpicker', ext:'aar')
|
||||
compile files('libs/twitter4j-core-4.0.4.jar')
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
|
@ -122,6 +122,16 @@ public class MainActivity extends AppCompatActivity
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause(){
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume(){
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Preferences
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.SharedPreferences;
|
|||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -14,16 +13,24 @@ import android.widget.EditText;
|
|||
import android.widget.NumberPicker;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.flask.colorpicker.ColorPickerView;
|
||||
import com.flask.colorpicker.OnColorSelectedListener;
|
||||
import com.flask.colorpicker.builder.ColorPickerDialogBuilder;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
|
||||
public class AppSettings extends AppCompatActivity {
|
||||
public class AppSettings extends AppCompatActivity implements View.OnClickListener{
|
||||
|
||||
private Button delButon;
|
||||
private Button delButon,save_woeid, colorButton1, colorButton2;
|
||||
private int backgroundColor, fontColor;
|
||||
private int mode;
|
||||
private Switch toggleImg;
|
||||
private EditText woeId;
|
||||
private SharedPreferences settings;
|
||||
private NumberPicker load_factor;
|
||||
private Editor edit;
|
||||
private boolean modified = false;
|
||||
private boolean imgldr;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInst) {
|
||||
|
@ -34,19 +41,26 @@ public class AppSettings extends AppCompatActivity {
|
|||
int location = settings.getInt("woeid",23424829);
|
||||
edit = settings.edit();
|
||||
|
||||
Toolbar tool = (Toolbar) findViewById(R.id.toolbar_setting);
|
||||
load_factor = (NumberPicker)findViewById(R.id.tweet_load);
|
||||
delButon = (Button) findViewById(R.id.delete_db);
|
||||
toggleImg = (Switch) findViewById(R.id.toggleImg);
|
||||
woeId = (EditText) findViewById(R.id.woeid);
|
||||
colorButton1 = (Button) findViewById(R.id.color_background);
|
||||
colorButton2 = (Button) findViewById(R.id.color_font);
|
||||
save_woeid = (Button) findViewById(R.id.save_woeid);
|
||||
|
||||
delButon.setOnClickListener(this);
|
||||
colorButton1.setOnClickListener(this);
|
||||
colorButton2.setOnClickListener(this);
|
||||
save_woeid.setOnClickListener(this);
|
||||
|
||||
setSupportActionBar(tool);
|
||||
load_factor.setMinValue(5);
|
||||
load_factor.setMaxValue(100);
|
||||
toggleImg.setChecked(settings.getBoolean("image_load",false));
|
||||
load_factor.setValue(settings.getInt("preload",10));
|
||||
woeId.setText(""+location);
|
||||
|
||||
loadSettings();
|
||||
setListener();
|
||||
}
|
||||
|
||||
|
@ -54,7 +68,7 @@ public class AppSettings extends AppCompatActivity {
|
|||
* Create Actionbar
|
||||
*/
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu m) {
|
||||
public boolean onCreateOptionsMenu( Menu m ) {
|
||||
getMenuInflater().inflate(R.menu.setting, m);
|
||||
return true;
|
||||
}
|
||||
|
@ -63,7 +77,7 @@ public class AppSettings extends AppCompatActivity {
|
|||
* Actionbar selection
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
public boolean onOptionsItemSelected( MenuItem item ) {
|
||||
switch(item.getItemId()) {
|
||||
case R.id.back_settings:
|
||||
finish();
|
||||
|
@ -74,26 +88,73 @@ public class AppSettings extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
edit.putInt("woeid", Integer.valueOf(woeId.getText().toString()));
|
||||
edit.putInt("preload", load_factor.getValue());
|
||||
edit.apply();
|
||||
if(modified) {
|
||||
edit.putInt("woeid", Integer.valueOf(woeId.getText().toString()));
|
||||
edit.putInt("preload", load_factor.getValue());
|
||||
edit.putInt("background", backgroundColor);
|
||||
edit.putInt("fontColor", fontColor);
|
||||
edit.putBoolean("image_load", imgldr);
|
||||
edit.apply();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch(v.getId()) {
|
||||
case R.id.delete_db:
|
||||
deleteDatabase(getString(R.string.database));
|
||||
break;
|
||||
case R.id.color_background:
|
||||
mode=0;
|
||||
setColorPicker();
|
||||
break;
|
||||
case R.id.color_font:
|
||||
mode=1;
|
||||
setColorPicker();
|
||||
break;
|
||||
case R.id.save_woeid:
|
||||
modified=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void setListener() {
|
||||
toggleImg.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton b, boolean checked) {
|
||||
edit.putBoolean("image_load", checked);
|
||||
edit.apply();
|
||||
}
|
||||
});
|
||||
|
||||
delButon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getApplicationContext().deleteDatabase(getApplicationContext().getString(R.string.database));
|
||||
imgldr = checked;
|
||||
modified = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadSettings() {
|
||||
backgroundColor = settings.getInt("background",10);
|
||||
fontColor = settings.getInt("fontColor",10);
|
||||
}
|
||||
|
||||
private void setColorPicker() {
|
||||
ColorPickerDialogBuilder.with(this)
|
||||
.showAlphaSlider(false)
|
||||
.wheelType(ColorPickerView.WHEEL_TYPE.CIRCLE).density(20)
|
||||
.setOnColorSelectedListener(new OnColorSelectedListener() {
|
||||
@Override
|
||||
public void onColorSelected(int i) {
|
||||
changeColor(i);
|
||||
}
|
||||
}).build().show();
|
||||
}
|
||||
|
||||
private void changeColor(int color) {
|
||||
switch(mode){
|
||||
case(0):
|
||||
backgroundColor = color;
|
||||
break;
|
||||
case(1):
|
||||
fontColor = color;
|
||||
break;
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
}
|
|
@ -11,6 +11,28 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/color_background"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/color_font"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/color_link"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -24,36 +46,34 @@
|
|||
android:id="@+id/tweet_load"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp">
|
||||
|
||||
<Switch
|
||||
android:id="@+id/toggleImg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_margin="10dp"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/woeid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_woeid"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
tools:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
|
|
|
@ -75,5 +75,6 @@
|
|||
<string name="banner">Profilbanner</string>
|
||||
<string name="link">Webseite</string>
|
||||
<string name="location">Ort</string>
|
||||
<string name="save">Speichern</string>
|
||||
|
||||
</resources>
|
|
@ -12,5 +12,6 @@ buildscript {
|
|||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
flatDir{ dirs 'libs'}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue