or-dvir / EasySettings

A library for easily creating and adding settings (AKA preferences) to your android app
Apache License 2.0
95 stars 18 forks source link

Settings click event #10

Closed AlbertIntelligence closed 4 years ago

AlbertIntelligence commented 4 years ago

BasicSettingsClickEvent don't work how do you do click event on a settings? @or-dvir

or-dvir commented 4 years ago

hi there. i havent touched this code in a long time... but it should work. did you do exactly like the sample app? can you share your code?

AlbertIntelligence commented 4 years ago

Not exactly exactly but I did my own implementation on my app, basically onBasicSettingsClicked is apparently never used according the android IDE.It not a override function so I don't know how your code launch the click event on mySettingsList

`import android.annotation.TargetApi; import android.content.Intent; import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.preference.Preference; import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;

import com.hotmail.or_dvir.easysettings.events.BasicSettingsClickEvent; import com.hotmail.or_dvir.easysettings.pojos.BasicSettingsObject; import com.hotmail.or_dvir.easysettings.pojos.CheckBoxSettingsObject; import com.hotmail.or_dvir.easysettings.pojos.EasySettings; import com.hotmail.or_dvir.easysettings.pojos.SettingsObject;

import org.greenrobot.eventbus.Subscribe;

import java.util.ArrayList;

import app.astracoins.crypto.R;

public class SettingsActivity extends AppCompatActivity { private ArrayList settingsList; @Override protected void onCreate(Bundle savedInstanceState) { //this is the settings activity

    super.onCreate(savedInstanceState);
    setContentView(R.layout.acitivity_settings);
    LinearLayout container = findViewById(R.id.settingsContainer);

    ArrayList<SettingsObject> mySettingsList = EasySettings.createSettingsArray(
            new BasicSettingsObject.Builder("settingloader", "Settings Loader")
                    .setSummary("LOAD SETTINGS FROM QR")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey2","Company settings")
                    .setSummary("COMPANY INFO SHOWED IN RECIEPT")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey1", "Owner PIN")
                    .setSummary("CHANGE OWNER PIN")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey1", "Merchant list")
                    .setSummary("ADD, EDIT OR REMOVE MERCHANTS")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey1", "Fees")
                    .setSummary("EDIT FEES AND LIMITS")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey1", "Used crypto")
                    .setSummary("SELECT CURRENCIES WHICH ARE USED")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey1", "Used fiat")
                    .setSummary("SELECT CURRENCIES WHICH ARE USED")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey1", "Language")
                    .setSummary("SELECT LANGUAGE")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey1", "Printer test")
                    .setSummary("PRINT THE SAMPLE RECIEPTS")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey1", "Reset all")
                    .setSummary("CLEAR SETTINGS AND RESTART APP")
                    .build(),
            new BasicSettingsObject.Builder("basicSettingsKey1", "Close")
                    .setSummary("CLOSE APPLICATION")
                    .build());

    //settingsList = (ArrayList<SettingsObject>) getIntent().getSerializableExtra(MainActivity.EXTRA_SETTINGS_LIST);

    EasySettings.inflateSettingsLayout(this, container, mySettingsList);

}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void stopLockState() {
    stopLockTask();
}

@Subscribe
public void onBasicSettingsClicked(BasicSettingsClickEvent event)
{

    if(event.getClickedSettingsObj().getKey().equals("settingloader")) {
        stopLockState();

}
}`
or-dvir commented 4 years ago

onBasicSettingsClicked is apparently never used according the android IDE.It not a override function so I don't know how your code launch the click event on mySettingsList

it is not called directly, but is used by EventBus. anyways ill try having a look but this is pretty old code for me and unfortunately i dont have much time these days. ill see what i can do...

AlbertIntelligence commented 4 years ago

Ok close the issue with evenBus it working thank you

or-dvir commented 4 years ago

glad to hear