Code Cleanup
Added Multiple Image Upload
New Window Animation
This commit is contained in:
NudeDude 2018-02-26 18:28:25 +01:00
parent da490f26cf
commit 82cf932164
5 changed files with 60 additions and 46 deletions

View File

@ -7,6 +7,7 @@ import android.content.SharedPreferences.Editor;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -28,32 +29,32 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
private EditText woeId; private EditText woeId;
private SharedPreferences settings; private SharedPreferences settings;
private ColorPreferences mColor;
private ClipboardManager clip; private ClipboardManager clip;
private TextView load_factor; private TextView load_factor;
private ColorPreferences mColor; private CheckBox toggleImg;
private int row, wId; private int row, wId;
private boolean imgEnabled;
@Override @Override
protected void onCreate(Bundle savedInst) { protected void onCreate(Bundle savedInst) {
super.onCreate(savedInst); super.onCreate(savedInst);
setContentView(R.layout.settings); setContentView(R.layout.settings);
mColor = ColorPreferences.getInstance(this);
settings = getApplicationContext().getSharedPreferences("settings", 0); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_setting);
clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); setSupportActionBar(toolbar);
row = settings.getInt("preload",10); if(getSupportActionBar() != null)
wId = settings.getInt("woeid",23424829); getSupportActionBar().setDisplayShowTitleEnabled(false);
String location = Integer.toString(wId);
String load = Integer.toString(row);
Button delButon = (Button) findViewById(R.id.delete_db); Button delButon = (Button) findViewById(R.id.delete_db);
CheckBox toggleImg = (CheckBox) findViewById(R.id.toggleImg);
Button colorButton1 = (Button) findViewById(R.id.color_background); Button colorButton1 = (Button) findViewById(R.id.color_background);
Button colorButton2 = (Button) findViewById(R.id.color_font); Button colorButton2 = (Button) findViewById(R.id.color_font);
Button colorButton3 = (Button) findViewById(R.id.color_tweet); Button colorButton3 = (Button) findViewById(R.id.color_tweet);
Button colorButton4 = (Button) findViewById(R.id.highlight_color); Button colorButton4 = (Button) findViewById(R.id.highlight_color);
Button reduce = (Button) findViewById(R.id.less); Button reduce = (Button) findViewById(R.id.less);
Button enhance = (Button) findViewById(R.id.more); Button enhance = (Button) findViewById(R.id.more);
Button clip = (Button) findViewById(R.id.woeid_clip); Button clipButton = (Button) findViewById(R.id.woeid_clip);
toggleImg = (CheckBox) findViewById(R.id.toggleImg);
load_factor = (TextView)findViewById(R.id.number_row); load_factor = (TextView)findViewById(R.id.number_row);
woeId = (EditText) findViewById(R.id.woeid); woeId = (EditText) findViewById(R.id.woeid);
@ -65,21 +66,15 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
toggleImg.setOnCheckedChangeListener(this); toggleImg.setOnCheckedChangeListener(this);
reduce.setOnClickListener(this); reduce.setOnClickListener(this);
enhance.setOnClickListener(this); enhance.setOnClickListener(this);
clip.setOnClickListener(this); clipButton.setOnClickListener(this);
int color1 = mColor.getColor(ColorPreferences.BACKGROUND); mColor = ColorPreferences.getInstance(this);
int color2 = mColor.getColor(ColorPreferences.FONT_COLOR); colorButton1.setBackgroundColor(mColor.getColor(ColorPreferences.BACKGROUND));
int color3 = mColor.getColor(ColorPreferences.TWEET_COLOR); colorButton2.setBackgroundColor(mColor.getColor(ColorPreferences.FONT_COLOR));
int color4 = mColor.getColor(ColorPreferences.HIGHLIGHTING); colorButton3.setBackgroundColor(mColor.getColor(ColorPreferences.TWEET_COLOR));
colorButton1.setBackgroundColor(color1); colorButton4.setBackgroundColor( mColor.getColor(ColorPreferences.HIGHLIGHTING));
colorButton2.setBackgroundColor(color2);
colorButton3.setBackgroundColor(color3);
colorButton4.setBackgroundColor(color4);
toggleImg.setChecked(settings.getBoolean("image_load",true)); loadSettings();
load_factor.setText(load);
woeId.setText(location);
} }
@Override @Override
@ -91,22 +86,14 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
@Override @Override
public boolean onOptionsItemSelected( MenuItem item ) { public boolean onOptionsItemSelected( MenuItem item ) {
switch(item.getItemId()) { switch(item.getItemId()) {
case R.id.save_settings:
save();
return true;
case R.id.back_settings: case R.id.back_settings:
finish(); finish();
return true; return true;
default:return false;
} }
return false;
}
@Override
public void onBackPressed() {
wId = Integer.parseInt(woeId.getText().toString());
Editor edit = settings.edit();
edit.putInt("woeid", wId);
edit.putInt("preload", row);
edit.commit();
mColor.commit();
super.onBackPressed();
} }
@Override @Override
@ -170,6 +157,30 @@ public class AppSettings extends AppCompatActivity implements View.OnClickListen
@Override @Override
public void onCheckedChanged(CompoundButton b, boolean checked) { public void onCheckedChanged(CompoundButton b, boolean checked) {
settings.edit().putBoolean("image_load", checked).apply(); imgEnabled = true;
}
private void loadSettings() {
settings = getApplicationContext().getSharedPreferences("settings", 0);
clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
row = settings.getInt("preload",10);
wId = settings.getInt("woeid",23424829);
imgEnabled = settings.getBoolean("image_load",true);
String location = Integer.toString(wId);
woeId.setText(location);
toggleImg.setChecked(imgEnabled);
String load = Integer.toString(row);
load_factor.setText(load);
}
private void save() {
wId = Integer.parseInt(woeId.getText().toString());
Editor edit = settings.edit();
edit.putInt("woeid", wId);
edit.putInt("preload", row);
edit.putBoolean("image_load", imgEnabled);
edit.apply();
mColor.commit();
} }
} }

View File

@ -43,8 +43,6 @@ public class TweetPopup extends AppCompatActivity implements View.OnClickListene
if(getIntent().hasExtra("Addition")) if(getIntent().hasExtra("Addition"))
addition = getIntent().getExtras().getString("Addition"); addition = getIntent().getExtras().getString("Addition");
// final int size = LinearLayout.LayoutParams.WRAP_CONTENT;
// getWindow().setLayout(size, size);
mediaPath = new ArrayList<>(); mediaPath = new ArrayList<>();

View File

@ -2,10 +2,15 @@
<menu xmlns:app="http://schemas.android.com/apk/res-auto" <menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/save_settings"
android:icon="@drawable/save"
android:title="save"
app:showAsAction="always" />
<item <item
android:id="@+id/back_settings" android:id="@+id/back_settings"
android:checkable="false" android:checkable="false"
android:icon="@drawable/back" android:icon="@drawable/right"
android:title="@string/back" android:title="@string/back"
android:visible="true" android:visible="true"
app:showAsAction="always" /> app:showAsAction="always" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#3F51B5</color> <color name="colorPrimary">#3f51b5</color>
<color name="colorPrimaryDark">#303f9f</color> <color name="colorPrimaryDark">#303f9f</color>
<color name="colorAccent">#ff4081</color> <color name="colorAccent">#ff4081</color>
<color name="twitterBlau">#034059</color> <color name="twitterBlau">#034059</color>

View File

@ -6,17 +6,17 @@
<item name="android:windowAnimationStyle">@style/TransactionPending</item> <item name="android:windowAnimationStyle">@style/TransactionPending</item>
<item name="android:navigationBarColor">@android:color/background_dark</item> <item name="android:navigationBarColor">@android:color/background_dark</item>
<item name="android:colorBackground">@color/DarkBlue</item> <item name="android:colorBackground">@color/DarkBlue</item>
<item name="android:statusBarColor">@color/transparent</item> <item name="android:statusBarColor">@android:color/transparent</item>
</style> </style>
<style name="Transparency" parent="AppTheme"> <style name="Transparency" parent="AppTheme">
<item name="android:windowIsTranslucent">true</item> <item name="android:windowIsTranslucent">true</item>
<item name="android:colorBackground">@android:color/transparent</item>
</style> </style>
<style name="TransactionPending" parent="@android:style/Animation.Activity"> <style name="TransactionPending" parent="@android:style/Animation.Translucent">
<item name="android:activityOpenEnterAnimation">@android:anim/fade_in</item> <item name="android:windowEnterAnimation">@android:anim/fade_in</item>
<item name="android:activityOpenExitAnimation">@android:anim/fade_out</item> <item name="android:windowExitAnimation">@android:anim/fade_out</item>
<item name="android:activityCloseEnterAnimation">@android:anim/fade_in</item>
<item name="android:activityCloseExitAnimation">@android:anim/fade_out</item>
</style> </style>
</resources> </resources>