Skip to content

Commit

Permalink
v0.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
tateisu committed May 15, 2017
1 parent e9e03cd commit 8eff080
Show file tree
Hide file tree
Showing 16 changed files with 1,133 additions and 379 deletions.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "jp.juggler.subwaytooter"
minSdkVersion 21
targetSdkVersion 25
versionCode 55
versionName "0.5.5"
versionCode 56
versionName "0.5.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme.Light"
android:largeHeap="true"
>
<receiver android:name=".AlarmReceiver">
<intent-filter>
Expand Down Expand Up @@ -138,6 +139,7 @@
<activity
android:name=".ActColumnCustomize"
android:label="@string/color_and_background"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
/>

<activity
Expand Down
140 changes: 90 additions & 50 deletions app/src/main/java/jp/juggler/subwaytooter/ActColumnCustomize.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;

import com.jrummyapps.android.colorpicker.ColorPickerDialog;
import com.jrummyapps.android.colorpicker.ColorPickerDialogListener;

import java.util.Locale;

import jp.juggler.subwaytooter.util.LogCategory;
import jp.juggler.subwaytooter.util.Utils;

Expand All @@ -42,7 +47,7 @@ public static void open( ActMain activity, int idx, int request_code ){
private void makeResult(){
Intent data = new Intent();
data.putExtra( EXTRA_COLUMN_INDEX, column_index );
setResult( RESULT_OK ,data);
setResult( RESULT_OK, data );
}

int column_index;
Expand Down Expand Up @@ -177,16 +182,14 @@ private void makeResult(){
View llColumnHeader;
ImageView ivColumnHeader;
TextView tvColumnName;

EditText etAlpha;

static final int PROGRESS_MAX = 65536;

private void initUI(){
setContentView( R.layout.act_column_customize );


Styler.fixHorizontalPadding(findViewById( R.id.svContent ));

Styler.fixHorizontalPadding( findViewById( R.id.svContent ) );

findViewById( R.id.btnHeaderBackgroundEdit ).setOnClickListener( this );
findViewById( R.id.btnHeaderBackgroundReset ).setOnClickListener( this );
Expand All @@ -197,7 +200,6 @@ private void initUI(){
findViewById( R.id.btnColumnBackgroundImage ).setOnClickListener( this );
findViewById( R.id.btnColumnBackgroundImageReset ).setOnClickListener( this );


llColumnHeader = findViewById( R.id.llColumnHeader );
ivColumnHeader = (ImageView) findViewById( R.id.ivColumnHeader );
tvColumnName = (TextView) findViewById( R.id.tvColumnName );
Expand All @@ -218,52 +220,90 @@ private void initUI(){

@Override
public void onProgressChanged( SeekBar seekBar, int progress, boolean fromUser ){
if( fromUser ){
column.column_bg_image_alpha = progress / (float)PROGRESS_MAX;
ivColumnBackground.setAlpha( column.column_bg_image_alpha );
}
if( loading_busy ) return;
if( ! fromUser ) return;
column.column_bg_image_alpha = progress / (float) PROGRESS_MAX;
ivColumnBackground.setAlpha( column.column_bg_image_alpha );
etAlpha.setText( String.format( Locale.JAPAN, "%.4f", column.column_bg_image_alpha ) );
}

} );

etAlpha = (EditText) findViewById( R.id.etAlpha );
etAlpha.addTextChangedListener( new TextWatcher() {
@Override
public void beforeTextChanged( CharSequence s, int start, int count, int after ){

}

@Override public void onTextChanged( CharSequence s, int start, int before, int count ){

}

@Override public void afterTextChanged( Editable s ){
if( loading_busy ) return;
try{
float f = Float.parseFloat( etAlpha.getText().toString() );
if( ! Float.isNaN( f ) ){
if( f < 0f ) f = 0f;
if( f > 1f ) f = 1f;
column.column_bg_image_alpha = f;
ivColumnBackground.setAlpha( column.column_bg_image_alpha );
sbColumnBackgroundAlpha.setProgress( (int) ( 0.5f + f * PROGRESS_MAX ) );
}
}catch( Throwable ex ){
log.e( ex, "alpha parse failed." );
}
}
} );
}

boolean loading_busy;

private void show(){
int c = column.header_bg_color;
if( c == 0 ){
llColumnHeader.setBackgroundResource( R.drawable.btn_bg_ddd );
}else{
ViewCompat.setBackground( llColumnHeader,Styler.getAdaptiveRippleDrawable(
c,
(column.header_fg_color != 0 ? column.header_fg_color :
Styler.getAttributeColor( this,R.attr.colorRippleEffect ))
) );
}

c = column.header_fg_color;
if( c == 0 ){
tvColumnName.setTextColor( Styler.getAttributeColor( this, android.R.attr.textColorPrimary ) );
Styler.setIconDefaultColor( this, ivColumnHeader, Column.getIconAttrId( column.column_type ) );
}else{
tvColumnName.setTextColor( c );
Styler.setIconCustomColor( this, ivColumnHeader, c, Column.getIconAttrId( column.column_type ) );
}

tvColumnName.setText( column.getColumnName( false ));

if( column.column_bg_color != 0 ){
flColumnBackground.setBackgroundColor( column.column_bg_color );
}else{
ViewCompat.setBackground( flColumnBackground, null );
}

float alpha =column.column_bg_image_alpha;
if( Float.isNaN( alpha )){
alpha = column.column_bg_image_alpha = 1f;
try{
loading_busy = true;
int c = column.header_bg_color;
if( c == 0 ){
llColumnHeader.setBackgroundResource( R.drawable.btn_bg_ddd );
}else{
ViewCompat.setBackground( llColumnHeader, Styler.getAdaptiveRippleDrawable(
c,
( column.header_fg_color != 0 ? column.header_fg_color :
Styler.getAttributeColor( this, R.attr.colorRippleEffect ) )
) );
}

c = column.header_fg_color;
if( c == 0 ){
tvColumnName.setTextColor( Styler.getAttributeColor( this, android.R.attr.textColorPrimary ) );
Styler.setIconDefaultColor( this, ivColumnHeader, Column.getIconAttrId( column.column_type ) );
}else{
tvColumnName.setTextColor( c );
Styler.setIconCustomColor( this, ivColumnHeader, c, Column.getIconAttrId( column.column_type ) );
}

tvColumnName.setText( column.getColumnName( false ) );

if( column.column_bg_color != 0 ){
flColumnBackground.setBackgroundColor( column.column_bg_color );
}else{
ViewCompat.setBackground( flColumnBackground, null );
}

float alpha = column.column_bg_image_alpha;
if( Float.isNaN( alpha ) ){
alpha = column.column_bg_image_alpha = 1f;
}
ivColumnBackground.setAlpha( alpha );
sbColumnBackgroundAlpha.setProgress( (int) ( 0.5f + alpha * PROGRESS_MAX ) );

etAlpha.setText( String.format( Locale.getDefault(), "%.4f", column.column_bg_image_alpha ) );

loadImage( ivColumnBackground, column.column_bg_image );
}finally{
loading_busy = false;
}
ivColumnBackground.setAlpha( alpha );
sbColumnBackgroundAlpha.setProgress( (int) ( 0.5f + alpha * PROGRESS_MAX ) );

loadImage( ivColumnBackground, column.column_bg_image );
}

String last_image_uri;
Expand All @@ -285,27 +325,27 @@ private void closeBitmaps(){

private void loadImage( ImageView ivColumnBackground, String url ){
try{
if( TextUtils.isEmpty(url ) ){
if( TextUtils.isEmpty( url ) ){
closeBitmaps();
return;

}else if( url.equals( last_image_uri ) ){
// 今表示してるのと同じ
return;
}

// 直前のBitmapを掃除する
closeBitmaps();

// 画像をロードして、成功したら表示してURLを覚える
int resize_max = (int) ( 0.5f + 64f * density );
Uri uri = Uri.parse( url );
last_image_bitmap = Utils.createResizedBitmap( log, this, uri,false, resize_max );
last_image_bitmap = Utils.createResizedBitmap( log, this, uri, false, resize_max );
if( last_image_bitmap != null ){
ivColumnBackground.setImageBitmap( last_image_bitmap );
last_image_uri = url;
}

}catch( Throwable ex ){
ex.printStackTrace();
}
Expand Down

0 comments on commit 8eff080

Please sign in to comment.