package com.lemenzo.clock.timer;
import android.app.*;import android.content.*;import android.graphics.Typeface;import android.os.Bundle;import android.view.*;import android.widget.*;import com.lemenzo.clock.R;import com.lemenzo.clock.util.Ui;
public final class TimerRingingActivity extends Activity {
    private long id;
    @Override protected void onCreate(Bundle b){super.onCreate(b);setShowWhenLocked(true);setTurnScreenOn(true);getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);id=getIntent().getLongExtra(TimerIntentActions.EXTRA_ID,-1);TimerItem t=new TimerRepository(this).get(id);LinearLayout root=new LinearLayout(this);root.setOrientation(LinearLayout.VERTICAL);root.setGravity(Gravity.CENTER);root.setPadding(Ui.dp(this,28),Ui.dp(this,36),Ui.dp(this,28),Ui.dp(this,36));root.setBackgroundColor(Ui.BLACK);TextView badge=Ui.badge(this,getString(R.string.ringing_badge));root.addView(badge,new LinearLayout.LayoutParams(-2,Ui.dp(this,30)));root.addView(Ui.space(this,16));TextView title=Ui.title(this,t==null||t.label.isEmpty()?getString(R.string.timer_ringing_title):t.label,30);title.setGravity(Gravity.CENTER);root.addView(title,new LinearLayout.LayoutParams(-1,0,1));TextView done=Ui.text(this,getString(R.string.timer_finished),18,Ui.SILVER);done.setGravity(Gravity.CENTER);root.addView(done);TextView hint=Ui.text(this,getString(R.string.timer_ringing_subtitle),14,Ui.SILVER);hint.setGravity(Gravity.CENTER);hint.setPadding(0,Ui.dp(this,8),0,Ui.dp(this,20));root.addView(hint);Button add=Ui.primary(this,getString(R.string.add_minute));add.setOnClickListener(v->act(TimerIntentActions.ADD_MINUTE));root.addView(add,new LinearLayout.LayoutParams(-1,-2));root.addView(Ui.space(this,10));Button stop=Ui.button(this,getString(R.string.dismiss));stop.setOnClickListener(v->act(TimerIntentActions.DISMISS));root.addView(stop,new LinearLayout.LayoutParams(-1,-2));setContentView(root);Ui.applySystemSafeInsets(this,root);}
    private void act(String action){sendBroadcast(new Intent(this,TimerReceiver.class).setAction(action).putExtra(TimerIntentActions.EXTRA_ID,id));finishAndRemoveTask();}
}
